Question: Say I have the following list:

```
<cfset myList = "1a,2b,3c,aa,bb,cc" >

```

How do I sort this list so that it will be "aa,bb,cc,1a,2b,3c"? In other words, I want anything that starts with a number to be at the end of the list and in order of the number it starts with.

Answer: 
This will work if you are on CF10+.

```
<cfscript>
    values = listToArray("1a,2b,3c,aa,bb,cc");
    arraySort(values, function(e1, e2) {
        var diff = val(e1) - val(e2);
        if(diff != 0)
            return diff;
        return e1 < e2 ? -1 : 1;
    });
    writedump(values);
</cfscript>

```

Run: <http://www.trycf.com/scratch-pad/pastebin?id=kKY9y2Nn>

**UPDATE**

But since you're using CF9:

```
<cfscript>
    function customSort(input) {
        var sorted = false;
        while (!sorted) {
            sorted = true;
            for (var i = 1; i < arrayLen(input); i++) {
                var e1 = input[i];
                var e2 = input[i + 1];
                var diff = val(e1) - val(e2);
                if (diff == 0 ? e1 > e2 : diff > 0) {
                    arraySwap(input, i, i + 1);
                    local.sorted = false;
                }
            }
        }
        return input;
    }
    values = listToArray("1a,2b,3c,3a,aa,bb,cc");
    writeDump(customSort(values));
</cfscript>

```

Run: <http://www.trycf.com/scratch-pad/pastebin?id=XK3fQv9T>
@Henry had a working answer for my CF9 server however when I plugged in my list with 2000 or so items in it, this method would have a significant delay, so I ended up coming up with my own way of doing this which turned out to be super fast:

```
<cfset digits = "0,1,2,3,4,5,6,7,8,9">
<cfset numList = "">

<cfloop index="item" list="#arguments.input#">
    <cfif ListFindNoCase(digits, Left(item, 1)) >
        <cfset numindex = ListFindNoCase(arguments.input, item) >
        <cfset numList = ListAppend(numList, item)>
        <cfset arguments.input = ListDeleteAt(arguments.input, numindex) >
    </cfif>
</cfloop>

<cfset numList = ListSort(numList, "textnocase", "asc") >
<cfset arguments.input = ListSort(arguments.input, "textnocase", "asc") >
<cfset arguments.input = ListAppend(arguments.input, numList)>

<cfreturn arguments.input >

```