Python's UUIDs are sorted according to the int
property which is the only member of a UUID object.
def __cmp__(self, other):
if isinstance(other, UUID):
return cmp(self.int, other.int)
return NotImplemented
This is different from the "timestamp" part of the UUID v1 object (which you can access as the time
property) because they refer to the underlying byte sequnce with different orders:
>>> x = uuid.uuid1()
>>> x
UUID('488085a8-be83-11e3-a999-1803733f0b7d')
>>> x.int
96371740624175594482388131032705469309L
>>> ((((((((((x.time_low << 16) | x.time_mid) << 16) | x.time_hi_version) << 8) | x.clock_seq_hi_variant) << 8) | x.clock_seq_low) << 48) | x.node) == x.int
True
>>> x.time
136161884817622440L
>>> (((((x.time_hi_version & 0xFFF) << 16) | x.time_mid) << 32) | x.time_low) == x.time
True
So you need to specify the "time" property when you sort UUID v1 objects according to thier timestamps:
sorted(ss, key= lambda x: x[0].time)