javascript - How to sort an array of links by link? -


this interesting, sorting links content, how go using javascript?

sorry, meant: have this:
http://stackoverflow.com'>stack overflow
http://www.google.com'>google
, want this:
""google ""
""stack overflow ""
...the links having been sorted alphabetical order link.

once have array of links example be

jquery:

$('a').sort(function(a, b) {    = a.text; b = b.text;    return < b ? -1 : > b ? 1 : 0;  }); 

without:

array().slice.call(document.getelementsbytagname('a')).sort(function(a, b) {    = a.text; b = b.text;    return < b ? -1 : > b ? 1 : 0;  }); 

using jquery or whatever array of links

then sorts text in between tags


Comments