How can I sync two lists ? (BubbleSort)

Hello everyone, I am trying to make a leaderboard and I have two list, List1- Names and list2- Points.

List1 Items(Names): John,Peter,Andy,Lana,Jack

List2 Items(Points): 100,400,20,70,300

As you can see that data are fetched in a random order but I want to set the list2 in descending order and the List1 should follow the same pattern.The points allotted to the name will be same.
For eg-
List1(Names): Peter,Jack,John,Lana,Andy


I want the list to be set as shown above.

I have tried with an extension ListAddOn and it works fine for the Points list but I want to follow the Names list also.

I'm out of idea please help.

Don't bother with extensions.

You're here to learn how to do this yourself.

That being said, see

for how to associate the names and scores together more tightly and how to do sorting by insertion.

Also see

for how to display a list of pairs in 2 ListViews

Sorry, thanks for sharing these articles but it's not what I want.

You need a Listofpairs to do what you want, not two separate Lists.

Sajal explains how to sort sort a simple List ; you can sort a List of pairs similarly.

However to do what you seem to want with two Lists is impractical because when you sort, you change the index of the items in the simple List. Once you do that you get garbage (the Lists are no longer in sync). Use a ListofPairs. :slight_smile:

1 Like

Here is a better version of my max_scores doc:

For more list sorting options, see

which has various sorting techniques. I like my merge sort link.

By The Way, your thread title mentioned Bubble Sort.

Is that a hard requirement, or are you allowed to use other, more efficient, sorting techniques?

Also asked on Kodular, closing....