Very easy way to ascending sort a list

I accidentally found a very easy way to sort a list! :open_mouth:
I use TinyDB for sorting! Yes! Correct, TinyDB! :slight_smile:

Save a suffled list with TinyDB to local database as keys
and read back that keys, its ascending sorted anymore! :wink:

It works for letters;

and numbers too;

and if you want to prevent this weird fuction (as me!) just use ā€œcopy listā€ block between ā€œvalue to storeā€ and ā€œsorted listā€ block;

I’m not sure is this a function or bug, but after solve this (with spending hours!), I can use this in my advantage anymore! :smiley:

11 Likes

Good find, use the reverse block for descending :slight_smile:

4 Likes

Very interesting! But AFAIK dictionary uses LinkedHashMap, which has order. Not sure why.

2 Likes

wish to know that before fight with tinydb! :smiley:
thx..

see Evan’s feedback from the MIT App Inventor team here

I don’t that this would technically be always guaranteed. JSON objects are considered unordered, so the key-value mappings can appear in any order and the objects are equivalent. Our implementation of dictionaries always keeps the key order as set by the user. My guess is that when we read the JSON serialization back from TinyDB that the parser orders the keys (even though it’s not needed), and that because the JSON functionality is Android dependent it might even change behavior from version to version of Android.
(copied freom a Power user thread)

Taifun

@Gemi_Trafik, there’s no need to mark my post as solution as your topic will be closed after a month. :sweat_smile:
@Taifun thanks for clarifying!

thanks my fellow

1 Like

not working !!!

you can check this

well, the sort is alphanumeric…

111
12
22

you are most probably looking for a numeric sort?
if you want to use this solution make sure to always have the same length… for example

012
022
111

Taifun

2 Likes

I have two lists, list 1 and list 2
I want that when my list 1 is getting sorted(having numbers) that time I want my list 2 also sorted with respect to list 1 .
How is this possible with this method? Because my other list is getting sorted on his own