Array.Sort() is always ascending?

Hi,

I just wanted to confirm that using Array.Sort() will always sort by ascending order? I.e. [94, 23, 45, 6] would become [ 6, 23, 45, 94] and if we wanted to do descending for some reason it would be Array.Reverse (AFTER doing an Array.Sort())?

Cheers,
Anthony.

array.Reverse() is fine on its own. You don’t need array.Sort() before it, Reverse() will be able to do it all.

To clarify, the [94,23,45,6] array would need both a Sort() and a Reverse() to become [94,45,23,6], but a Sorted array just needs Reverse() to change the sort to descending.

3 Likes

Damn you’re right. I was thinking it sorted in reverse. ;( Good catch.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms