I want to create my own sort() function on an array in javascript. The function should expect the following string elements in the list [0-9]*[A-Z][0-9]*[A-Z][0-9]* That means first there are arbitrary number of numbers 0-9, then there is One letter, followed by arbitrary numbers 0-9, then One Letter and then finally arbitrary numbers 0-9. Now I want to sort this list, but I want to sort it backwards on the Letters Only. That means that for example [xExCx,xQxEx,xSxEx,xSxFx] will become after its sorted [xSxFx,xSxEx,xQxEx,xExCx] where again x is an arbitrary number of numbers 0-9. It will sort on the first letter (backwards) first and then the second letter. So that letter E comes before an A. Perhaps anyone of you brilliant guys could give me a push in the right direction, I have only gotten this far.
function sortList(listOfNames) {
var sortedListOfNames=new Array();
for (i = 0; i < listOfNames.length; i++) {
//Sort listOfNames
}
}
sort? developer.mozilla.org/en/docs/Web/JavaScript/Reference/… If you can create a simple snippet of code that does your custom letter comparison, you can easily write a callback that sorts by it.