I want to sort array like this:
["AAAA1", "AAAA3", "ABAA2", "AAAA10", "AAAA100", "BBB2", "BBB10", "BBAA3", "BBB2AA"]
when i sort it, returns me like:
["AAAA1", "AAAA10", "AAAA100", "AAAA3", "ABAA2", "BBAA3", "BBB10", "BBB2", "BBB2AA"]
That i like to sort it like this:
["AAAA1", "AAAA3", "AAAA10", "AAAA100", "ABAA2", "BBAA3", "BBB2", "BBB2AA", "BBB10"]
so i searched it in stackoverflow and i found something like under links but all of that haven`t general method for sorting characters & numbers string and only works for special questions!!
javascript: sort an array a certain way with integers and characters
How to sort number in javascript sort method
How to sort an array of integers correctly
Edit1:
Please check answers of questions in Sort JavaScript String Array containing numbers, the answer works with text with format var regex = /Value\s([0-9]+)/;
and or in Sort mixed alpha/numeric array the answer only works with one character at the beginning of the string.. that i need some method works with all possible string that contains characters and numbers ...!!
Edit2:
Tanx Felix Kling:
i`m so sorry, i have wrong order to array in example, so i liked to BBB2AA order before BBB10
I found the general method for doing that with add leading zero, i wrote a version of it now and please optimize it or give me another options for sorting like that http://jsfiddle.net/Qd8nd/