comparing a GUID so I can sort by GUID

delphi, guid, sorting

Solution

If you're using Delphi 2009 or better, you can use `TComparer<TGUID>.Compare()`, or the `BinaryCompare` function it calls, from the Generics.Defaults unit.

Problem

what's a nice, fast way to sort a list of GUIDs (as TGuid). i thought i'd just use SysUtils.CompareMem(P1, P2: Pointer; Length: Integer): Boolean; until i realized it returns boolean. i'd wish for something comparable to CompareText( ) or CompareValue( ) that return integer so it can be used in a sort comparison. i suppose not many people wish to sort GUIDs...any ideas? i suppose i could call make some cascading calls to CompareValue( ) on the contents of the TGuid record. my instincts tell me there must be a better way! thank you!

Original source

Related problems