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