alkemis a_sort javascript sort
A little JS library (namespaced as a js object) 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
[v.3] can sort JSON with varied data

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 (ie; "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 json


- paramObj (optional) .. is in json format
.. by ie; "innerHTML", "cells[1].innerHTML", (many other possibilities) - (optional)
.. customCompare "numeric", "currency", or func(a, b) - (optional - default is alphabetical)
.. reverseFlag - (optional)
.. caseInsensitiveFlag - (optional)
.. stripHTMLFlag - (optional)

Get it:
a_sort_03.packed.js (2.22kb packed)