There is bug in this extension, as mentioned here
Please use the new buildin 'sort list' block instead.
This is a simple extension, and now only have one block to sort a list:
Download link:
cn.kevinkun.listutil.aix (8.8 KB)
How to use
- make a procedure with 2 parameters, and return a number (integer or float both ok)
Example:
-
sort a list of number
![2022-05-13_103049](https://community.appinventor.mit.edu/uploads/default/original/3X/f/2/f28f2bb6a48010f1b2bf95bc32a20e07a1c425df.png)
-
sort a list of list according to 2nd item (a number) of sublist
![2022-05-13_103110](https://community.appinventor.mit.edu/uploads/default/original/3X/c/0/c06baab5186f78f7e2d0a81e195239fd5dbcfe60.png)
3, sort a list of list according to 1st item (a string) of sublist
![2022-05-13_103119](https://community.appinventor.mit.edu/uploads/default/original/3X/4/3/43353d5efc97c169ce0c63f7245783c07144027d.png)
- sort a list of list according to lenth of 1st item
![2022-05-13_103059](https://community.appinventor.mit.edu/uploads/default/original/3X/a/8/a8c600088936522b7e801c526af552f4063c2481.png)
if a decending list wanted, just change symbol of procedure's return value.
Credit
- "call function" is from @ewpatton;
- Extension build with Rush
13 Likes
Great!.. Such a wounderful extension. No need of multiple blocks to sort the list in desired mode.. You made it in very simple mannar..
![:heart: :heart:](https://community.appinventor.mit.edu/images/emoji/google/heart.png?v=10)
2 Likes
ABG
4
Do you have a link to the source?
This is an important piece of code.
TIMAI2
6
A couple more examples:
Sort List of Strings:
![image](https://community.appinventor.mit.edu/uploads/default/original/3X/6/5/65811eeea24f9c314510e7f05ab182a0af668c21.png)
![image](https://community.appinventor.mit.edu/uploads/default/original/3X/6/9/69c41cc8288c2a6c0845e589dae2ecde8cd13183.png)
"Filter" by contains
:
![image](https://community.appinventor.mit.edu/uploads/default/original/3X/b/8/b879b25e4dfe3610b602156474caec1fd0ed458a.png)
![image](https://community.appinventor.mit.edu/uploads/default/original/3X/7/d/7d34439bf486c799eabfd7d2a27a2472bf89a41e.png)
is there a way to exclude the list items that do not match ?
Maybe I should add filer and map function later.
I don't understand what are x and x2 in procedure and how it works...
you can give them any name you want. they represent two items from the list.
ok. and then result 1 means increase order and -1 decrease order...
i think it's ok. thanks
Taifun
Split this topic
11
10 posts were split to a new topic: How to sort a list of lists by date?