I’m currently rewriting the userlist implementation in an IM client interface that uses JavaScript. The names in this list are currently sorted alphabetically, and I want to edit this so that it only takes alphabetical characters in account when comparing strings.
For instance: “1foo” comes after “bar”, because “foo” comes after “bar”.
I know I could just create two temporary strings by removing all non-alphabetical characters from the two original strings, but I’m guessing that there must be easier ways to do this.
Well, if you have an array of strings called
arr, you can use this one-liner:arris now sorted taking only letters into account.