Doesn't sort? As in leaves the items in the order they were in before? We'd have to see your code and the result to know why.
As suspected, it was my mistake. I was sorting them after I break the variable in pieces. I have it fixed now.
however there is one minor problem, which I don't think there will be a solution. I am removing http://www part of the url but when the url doesn't have http://www. but has http://somedomain it wouldn't sort it correctly.
But that's alright for the time being.