Question: ```js
var table = 
    [
        {"name":"Joe", "Level":1}, 
        {"name":"Bob", "Level":1B}, 
        {"name":"Carl", "Level": 7},
        {"name":"Mike", "Level": 1A},
        {"name":"Sal", "Level": 2}
    ]
var tableHeaders = scope.SortTableColumnHeaders(table)

scope.SortTableColumnHeaders = function (array) {
        var unique = {};
        var distinct = [];
        for (var i in array) {
            if (typeof (unique[array[i].Level]) == "undefined") {
                distinct.push(array[i].Level);
            }
            unique[array[i].Level] = 0;
        }
        return distinct.sort();
    };
```

I have an object that looks like the above code where I pull out a distinct array like
[1,10,1A,1B,2,7]
where I can have int (1-10) and strings (1A, 1B, 1C)

I want to sort the int's in order first and then the strings second so it will always look like 
[1...10,1A,1B,1C]

I tried distinct.sort(), but that doesn't work.

Answer: 
Well, ASCII values are continuous, and numbers are lower than chars from the alphabet, so if you can live with the sum of the ASCII values (that would work with `1A`, `1B` and so on)

```
var table = [
   {"name":"Joe", "Level": '1'}, 
   {"name":"Bob", "Level": '1B'}, 
   {"name":"Carl", "Level": '7'},
   ...
]

function sortByCharCode(a,b) {
    function charCodeInt(s) {
        result = 0;
        for (var i=0;i<s.length;i++) {
            result += s.charCodeAt(i);
        }
        return result;
    } 
    a = charCodeInt(a.Level);
    b = charCodeInt(b.Level);
    if (a < b) return -1;
    if (a > b) return 1;
    return 0;
}

$scope.sortTable = function() {
   $scope.table.sort(sortByCharCode);
}

```
You can still use the sort method, passing a function to drive your criterias:

```
table.sort(function(a, b){
    var compA = a.Level;
    var compB = b.Level;
    if(isNaN(compA) && isNaN(compB)){
        return compA.localeCompare(compB);
    } else if(isNaN(compA)){
        return 1;
    } else if(isNaN(compB)){
        return -1;
    } else {
        return compA - compB;
    }
});

```

On this sorting you will sort numbers between themselves and the same for strings (1A, 1B ...). When sorting both together, number comes first.