alkemis a_sort javascript sort
A little, namespaced JS library that sorts almost anything.

Examples:
select id="someSelect"

a_sort.select("someSelect"); //default.. by:"text"
a_sort.select("someSelect", {caseInsensitiveFlag:true} ); //default.. by:"text"
a_sort.select("someSelect", {by:"value"} );


table id="someTable"
namenumberamount
aaa8$10.11
bbb9$.35
ddd10$8.56
ccc11$1.23
a_sort.table("someTable"); //default.. by:"innerHTML"
a_sort.table("someTable", {by:".cells[1].innerHTML"} );
a_sort.table("someTable", {by:".cells[1].innerHTML", customCompare:"numeric"} );
a_sort.table("someTable", {by:".cells[2].innerHTML", customCompare:"currency"} );
More table examples


ul id="someUl"
a_sort.list("someUl"); //default.. by:"innerHTML"
a_sort.list("someUl", {reverseFlag:true} ); //default.. by:"innerHTML"


div id="someDiv"
ggg
fff
sss
bbb
aaa
ggg

a_sort.childrenOf("someDiv","DIV"); //default.. by:"innerHTML"
a_sort.childrenOf("someDiv", "DIV", {reverseFlag:true} ); //default.. by:"innerHTML"


someJsonObj= {b:5,a:6,c:4,d:[9,10],e:true,f:3,g:{T:2},h:1};
someJsonObj=
someJsonObj= a_sort.collection(someJsonObj); //default.. by:"value"
someJsonObj= a_sort.collection(someJsonObj, {by:"_key"} ); //note: "_key" has special meaning for sorting json

anotherJsonObj= {"3":"abc", "-5":"xyz", "1000":"efg", "0":"jkl"};
anotherJsonObj=
anotherJsonObj= a_sort.collection(anotherJsonObj, {by:"_key", customCompare:"numeric"} );
anotherJsonObj= a_sort.collection(anotherJsonObj, {by:"_key", customCompare:"numeric", reverseFlag:true} );
Google Chrome doesnt think JSON like this should be orderable see issue. whatever.

stillAnotherJsonObj= [{"id":"1", "name":"fred"}, {"id":"3", "name":"abe"}, {"id":"2", "name":"zeke"}];
stillAnotherJsonObj=
stillAnotherJsonObj= a_sort.collection(stillAnotherJsonObj, {by:"name"} );
stillAnotherJsonObj= a_sort.collection(stillAnotherJsonObj, {by:"id"} );

API:
a_sort.select( selectElement [, paramObj] );
sorts the OPTIONs (default is by text)
- selectElement (required) is dom-element or id-string of a SELECT

a_sort.list( listElement [, paramObj] );
sorts the LIs (default is by innerHTML)
- listElement (required) is dom-element or id-string of a UL (or OL)

a_sort.table( tableElement [, paramObj] );
sorts the TRs in TBODY (default is by innerHTML)
- tableElement (required) is dom-element or id-string of a TABLE

a_sort.childrenOf( containerDomElement, tagString [, paramObj] ); [v.2]
sorts the dom-elements of tagString in the containerDomElement (default is by innerHTML)
- containerDomElement (required) is dom-element or id-string of a dom-element
- tagString (required) is a tag-string (e.g. "div", "span", etc.)


a_sort.collection( object [, paramObj] );
this is the core function in this library. The functions above use this. Generally, applications do not call this except for sorting JSON.
- object (required) can be array, or data-object


- paramObj (optional) .. is a data-object
.. by e.g. "innerHTML", "cells[1].innerHTML", (many other possibilities) - (optional)
.. customCompare e.g. "numeric", "currency", or func(a, b) - (optional - default is alphabetical)
.. reverseFlag - (optional)
.. caseInsensitiveFlag - (optional)
.. stripHTMLFlag - (optional)

Get it:
a_sort_04.packed.js (2.3kb packed)

bug: a_sort_03.packed.js, a_sort.select() didnt work in Safari, fixed in a_sort_04.packed.js.