September 6, 2007
Hi Guys
(38) Sort() method
The Array.Sort();method arranges array items in ascending order. It works numerically for number types and alphabetically for characters and strings.
But if array items are mix of numbers and alphabetical Array.Sort();method can’t be used. For example in order to sort zip code what method can be used. Please help.
zips = {"BF 45633", "GJ 76895", "BK 87946", "NM 38657"}
Thank you
AlanPosted Sep 6, 2007, 11:51 AM
You can in fact sort on a mixture of digits and letters contained in a string.
This is because string sorting is actually based on the unicode values of the constituent characters. Morover, the digits '0' to '9' correspond to consecutive unicode values of 48 to 57 which are lower than the unicode values of the letters 'A' to 'Z' (65 to 90) and 'a' to 'z' (97 to 122).
Just try it and see.