I am trying to sort a select option with value and text as follows . The Text can have special characters and it needs to be sorted . However I am finding that , some special characters are coming after alphabets . I want all special characters first and then Alphabets .
c = [["#test","#test"], ["?test", "?test"], ["test", "test"], ["TEst", "TEst"], ["]test", "]test"]]
>>> c.sort()
[["#test", "#test"], ["?test", "?test"], ["TEst", "TEst"], ["]test", "]test"], ["test", "test"]]
The problem seems to be 'TEst' .
Another simple example:
cool = ['#new','?new','[new',']new','NEw','&new','cool','ind']
["#new", "?new", "[new", "]new", "NEw", "&new", "cool", "ind"]
cool.sort()
["#new", "&new", "?new", "NEw", "[new", "]new", "cool", "ind"]