117
rated 0 times
[
119]
[
2]
/ answers: 1 / hits: 43278
/ 11 Years ago, mon, march 18, 2013, 12:00:00
I have an array like;
[IL0 Foo, PI0 Bar, IL10 Baz, IL3 Bob says hello]
And need to sort it so it appears like;
[IL0 Foo, IL3 Bob says hello, IL10 Baz, PI0 Bar]
I have tried a sort function;
function compare(a,b) {
if (a < b)
return -1;
if (a > b)
return 1;
return 0;
}
but this gives the order
[IL0 Foo, IL10 Baz, IL3 Bob says hello, PI0 Bar]
I have tried to think of a regex that will work but can't get my head around it.
If it helps the format will always be 2 letters, x amount of numbers, then any number of characters.
More From » jquery