Trying to create a custom sort function for an existing script

Edit - Got the code from the developer

I need some help modifying a script I’ve come across from here . It’s a great script that allows for dynamic table sorting, my challenge is that it really screws up the appearance of my table which is very reliant on CSS. Basically what’s happened is that every th that I’ve designated as [COLOR=green]class=“sortable”[/COLOR] (as per the script) is having the CSS’s formatting overwritten. Through looking over some of his sample code I’ve determined that if I can create a sortable function I can use CSS to customize it.

Example: Instead of using [COLOR=green]class=“sortable”[/COLOR] to sort a numeric column I can create a function that does exactly the same thing but name it [COLOR=green]class=“sortable-sortNumber”[/COLOR] and then in CSS I can customize it by using [COLOR=green]th.sortable-sortNumber[/COLOR].

The problem is that I have no idea, even after looking through his code, on how to create my own functions (two for numeric, two for text, one for date). All these features are present however I need to create five new functions so I can customize them.

Here’s an example of one of his “custom sort functions” for an IP address.

   This custom sort function correctly sorts IP addresses i.e. it checks all of the address parts and not just the first.

   The function is "safe" i.e. non-IP address data (like the word "Unknown") can be passed in and is sorted properly.
function sortIPAddress(a,b) {
        var aa = a[fdTableSort.pos];
        var bb = b[fdTableSort.pos];

        return aa - bb;
function sortIPAddressPrepareData(tdNode, innerText) {
        // Get the innerText of the TR nodes
        var aa = innerText;

        // Remove spaces
        aa = aa.replace(" ","");

        // If not an IP address then return -1
        if(^([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})$/) == -1) return -1;

        // Split on the "."
        aa = aa.split(".");

        // If we don't have 4 parts then return -1
        if(aa.length != 4) return -1;
        var retVal = "";
        // Make all the parts an equal length and create a master integer
        for(var i = 0; i < 4; i++) {
                retVal += (String(aa*).length < 3) ? "0000".substr(0, 3 - String(aa*).length) + String(aa*) : aa*;
        return retVal;

If it helps at all here’s the actual script itself in the attachment. I know what I’m trying to do is bound to be simple as hell… I just don’t know a lick of Java and I need this done in the next couple days on top of a bunch more site coding I’m working with. Thanks a ton for any help you can spare :smiley: