reference: https://docs.mongodb.org/manual/reference/object-id/ https://api.mongodb.org/python/current/api/bson/objectid.html
python
# coding=utf-8
from bson.objectid import ObjectId
print "# GEN"
oids = []
for x in range(10):
oid = str(ObjectId())
print oid
oids.append(oid)
print "# DESC"
oids.sort(reverse=True)
for oid in oids:
print oid
print "# ASC"
oids.sort()
for oid in oids:
print oid
GEN 5660f8b837dbc4066fd1c26b 5660f8b837dbc4066fd1c26c 5660f8b837dbc4066fd1c26d 5660f8b837dbc4066fd1c26e 5660f8b837dbc4066fd1c26f 5660f8b837dbc4066fd1c270 5660f8b837dbc4066fd1c271 5660f8b837dbc4066fd1c272 5660f8b837dbc4066fd1c273 5660f8b837dbc4066fd1c274 DESC 5660f8b837dbc4066fd1c274 5660f8b837dbc4066fd1c273 5660f8b837dbc4066fd1c272 5660f8b837dbc4066fd1c271 5660f8b837dbc4066fd1c270 5660f8b837dbc4066fd1c26f 5660f8b837dbc4066fd1c26e 5660f8b837dbc4066fd1c26d 5660f8b837dbc4066fd1c26c 5660f8b837dbc4066fd1c26b ASC 5660f8b837dbc4066fd1c26b 5660f8b837dbc4066fd1c26c 5660f8b837dbc4066fd1c26d 5660f8b837dbc4066fd1c26e 5660f8b837dbc4066fd1c26f 5660f8b837dbc4066fd1c270 5660f8b837dbc4066fd1c271 5660f8b837dbc4066fd1c272 5660f8b837dbc4066fd1c273 5660f8b837dbc4066fd1c274
Process finished with exit code 0
Recommended Posts