Share Link
Copied to clipboard
Embed on Your Page
Copied to clipboard
We Stand with Ukraine
[Fork] Compare sort order of Guid and SqlGuid by richardtallent
Little Endian? True
Demonstrate x86 DWORD byte order
 Decimal value: 254
 Hex value: 000000FE

Proving that byte F is sorted before byte 9
 ________-____-____-___2-___________1
 ________-____-____-___1-___________2

Proving that byte F is sorted before byte 8
 ________-____-____-_2__-___________1
 ________-____-____-_1__-___________2

Proving that byte 7 is sorted before byte 8
 ________-____-____-_1_2-___________1
 ________-____-____-_2_1-___________1

Proving that byte A is sorted bfeore byte F
 ________-____-____-____-___________4
 ________-____-____-____-1__________3
 ________-____-____-____-2__________2
 ________-____-____-____-3__________1

Byte order:
 ______42-____-____-____-____________
 ____11__-____-____-____-____________
 __22____-____-____-____-____________
 33______-____-____-____-____________
 ________-__44-____-____-____________
 ________-55__-____-____-____________
 ________-____-__66-____-____________
 ________-____-77__-____-____________
 ________-____-____-88__-____________
 ________-____-____-__99-____________
 ________-____-____-____-aa__________
 ________-____-____-____-__bb________
 ________-____-____-____-____cc______
 ________-____-____-____-______dd____
 ________-____-____-____-________ee__
 ________-____-____-____-__________ff

Guid Sort (string order, i.e., leftmost digits are bigger):
 ________-____-____-____-__________ff
 ________-____-____-____-________ee__
 ________-____-____-____-______dd____
 ________-____-____-____-____cc______
 ________-____-____-____-__bb________
 ________-____-____-____-aa__________
 ________-____-____-__99-____________
 ________-____-____-88__-____________
 ________-____-__66-____-____________
 ________-____-77__-____-____________
 ________-__44-____-____-____________
 ________-55__-____-____-____________
 ______42-____-____-____-____________
 ____11__-____-____-____-____________
 __22____-____-____-____-____________
 33______-____-____-____-____________

MSSQL/SqlGuids Sort (BYTES A-F, BYTES 8-9, WORD2, WORD1, DWORD):
 33______-____-____-____-____________
 __22____-____-____-____-____________
 ____11__-____-____-____-____________
 ______42-____-____-____-____________
 ________-55__-____-____-____________
 ________-__44-____-____-____________
 ________-____-77__-____-____________
 ________-____-__66-____-____________
 ________-____-____-__99-____________
 ________-____-____-88__-____________
 ________-____-____-____-__________ff
 ________-____-____-____-________ee__
 ________-____-____-____-______dd____
 ________-____-____-____-____cc______
 ________-____-____-____-__bb________
 ________-____-____-____-aa__________
Cached Result
Last Run: 1:07:54 pm
Compile: 0.215s
Execute: 0.016s
Memory: 48kb
CPU: 0.016s