List Sorting Incorrectly

cbanks

Active Member
Licensed User
Longtime User
I have the following code and it sorts Capitalized words before words that are lower case. Is there a way to fix that?

list1.Sort(True)

So, if my list was the following:

apple
dog
Zebra
Cat

It sorts it like this:

Cat
Zebra
apple
dog

I want it to sort like this:

apple
Cat
dog
Zebra
 

Ricky D

Well-Known Member
Licensed User
Longtime User
What I'd do is create a map putting keys as your values capitalized and your values in the value field then sort the map on the keys, building your list from that. I have to admit I don't know how to sort a map.

Regards Ricky
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
On second thoughts I'd throw the map keys & values into an sqlite table then read the table ordered by the key
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Another approach: If you do not mind them all appearing as lower or upper casein the list:
B4X:
Dim list1 As List
list1.Add("cbanks".ToUpperCase)   'or list1.Add("cbanks".ToLowerCase)
list1.Sort(True)

If I am not understanding the question, please ignore
Mahares
 
Upvote 0
Top