Skip to content
Advertisement

case-insensitive treeview sorting

I am using below code to sort the treeview column but it is case sensitive i.e. if the column value is [a,c,A] the sorted value will be [a,c,A]but i want it as [a,A,c] and even the number sorting is only based on first digit i.e. if [2,1,11] is the column value, the output will be [1,11,2] what i want it to be as [1,2,11]. please help me with the idea to solve this issue. Thank you

JavaScript

Advertisement

Answer

Case insensitive sorting is done by providing a key mapping function to sort. For example, sort(values, key=str.casefold) (Python 3).

In the case of sorting over the first value of the tuple, the data sort line would become data.sort(reverse=descending, key=lambda t: str.casefold(t[0]))

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement