Page 1 of 1

Alphabetizing Postcodes

Posted: Sat Aug 21, 2010 2:00 pm
by lacorp
Hi,
I need some help alphabetizing an array. The array is full of postcodes from England. When I try to sort() them though I end up with this:
[text]CM0 Southminster
CM1 Chelmsford
CM11 Billericay
CM12 Billericay
CM19 Harlow
CM2 Chelmsford
CM20 Harlow
[/text]

As you can probably guess, this isn't how I want them. I need them sorted numerically as well as alphabetically, so that they'll look like this:
[text]CM0 Southminster
CM1 Chelmsford
CM2 Chelmsford
CM11 Billericay
CM12 Billericay
CM19 Harlow
CM20 Harlow
[/text]
Any help would be greatly appreciated.

Thanks,
lacorp

(Please note that the actual dataset is much larger than what I used as an example)

Re: Alphabetizing Postcodes

Posted: Sat Aug 21, 2010 3:17 pm
by AbraCadaver
Try natsort().

Re: Alphabetizing Postcodes

Posted: Sat Aug 21, 2010 5:33 pm
by lacorp
That solved my problem completely. Thank you so much.