Created
March 28, 2012 15:14
-
-
Save JanPaulEttles/2227085 to your computer and use it in GitHub Desktop.
jandefence4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > var cursor = db.coll.find().sort({"someNumber":1}); | |
| > var max = -1; | |
| > while(cursor.hasNext()) { | |
| ... var current = parseInt(cursor.next().someNumber); | |
| ... print(max + ' ' + current); | |
| ... if(current > max) { | |
| ... print(max + ' ' + current); | |
| ... max = current; | |
| ... } | |
| ... } | |
| -1 1 | |
| -1 1 | |
| 1 10 | |
| 1 10 | |
| 10 100 | |
| 10 100 | |
| 100 110 | |
| 100 110 | |
| 110 120 | |
| 110 120 | |
| 120 150 | |
| 120 150 | |
| 150 20 | |
| 150 200 | |
| 150 200 | |
| 200 50 | |
| 200 90 | |
| > print(max); | |
| 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment