Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting Alphanumeric Keys - ksort 1

Status
Not open for further replies.

Extension

Programmer
Nov 3, 2004
311
CA
Hi,

I'm trying to sort some alphanumeric strings (Array Keys)
and it's not sorting correctly.

The keys are in the following:
Code:
type_23_12
reason_24_22
type_4_2
type_34_2

With ksort (SORT_STRING), I get the following order
Code:
reason_24_22
type_23_12
type_34_2 
type_4_2

But "type_4_2" should be before "type_23_12". The number "4" is treated differently.

Thank you in advance.
 

That's what I ended doing. Hacked out the number if lower than 10.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top