I’m terrible with math, but I need to be able to sort a string in JavaScript (or jQuery) in numeric-alpha order with zeroes at the end.
So to do this, I know I can convert the string into an array with myStr.split(”) and then call sort() with a custom sort function, so here is what I have so far:
function mysort(a, b) {
// not sure what to put here.
// order should be: 123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0
}
function sortMyString(str) {
str.split('');
return str.sort(mysort);
}
I would really appreciate help on this.
Thank you.
This will result in the string being the same as above, feel free to mix the string up, add more etc and it should come up in the order you want.
http://jsfiddle.net/dJMHK/