• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Why does .NET Array.Sort suck so bad...

Mark R

Diamond Member
Sorting ints

Sorted 16777216 items in 9796.875 ms using Array.Sort
Sorted 16777216 items in 6609.375 ms using explicitly coded quicksort (CLR)
Press any key to continue

Sorting floats

Sorted 1048576 items in 16609.375 ms using Array.Sort
Sorted 1048576 items in 375 ms using explicitly coded quicksort (CLR)
Press any key to continue

Sorting doubles

Sorted 1048576 items in 16796.875 ms using Array.Sort
Sorted 1048576 items in 390.625 ms using explicitly coded quicksort (CLR)
Press any key to continue

So, while sorting ints isn't bad - sorting floats/doubles is shocking.

What's up?
 
I'd guess its .net garbage collection / type checking at work..
another reason to go to school to become a programmer; built-in function are almost never optimzed for performance rather than compatibility.
 
If I'm sorting that many items and performance counts, you better believe I'm not going to use the built in sort functions.
 
Back
Top