Jump to content


Sort() an array, ignoring punctuation/spaces and case insensitive?


1 reply to this topic

#1 xwazawx

    Young Padawan

  • Members
  • Pip
  • 45 posts

Posted 13 January 2009 - 09:01 PM

Hello,
I have an array - I want to sort it with a function similar to sort() except I want it to be sorted by alphanumeric characters only.

So A. J. Williams would be after Abraham. And SGA would be after Safety..

Google's failed me on this one, and I'd rather not create a whole function for this o_O Any help would be much appreciated

Edited by xwazawx, 13 January 2009 - 09:02 PM.


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 14 January 2009 - 01:52 PM

The two options i know of off the top of my head:

natcasesort()
usort()

However, "A. J. Williams" should come before "Abraham" because of the space. At least in my view, that would be the case.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users