There may be a problem with the sorting method of List

This is the first time I use app inventor to develop a small game app .

After a week of programming, the project is basically completed.

In the final optimization, I found that all the methods involved in List sorting may have problems

For example:

Runtime errors will occur:“ Argument (package yail-list-sort, Unknown, version 0.0) to 'apply-to-args' has wrong type (java.lang.Package) (expected: procedure)”

the example given in the document also run not correctly.

in my simplest tests, such as the following blocks, do not work properly.

In the past, when my program went wrong, I tend to think it was my fault. Now this makes me crazy.

Who has the same experience as me? Or someone can tell me ,what did I missed

Are you using an emulator or Companion plus real device to program?

This similar example works in an Android 13 but not in the basic emulator. It returns the same error you receive.

The new List Blocks probably do not work in the original emulator or in Androids lower that a certain version.


It returns [10,11,13] to the label. (which returns the original order because the values are already in ascending order)

I use a real phone device ,android 11.
**In fact, list [10 11 13] is just one test. I have a list like [['string',number], ['string',number],['string',number],,,,,,,] **
**which has may be about 1000 items to sort.

now i have to write a function to sort list by myself.
but an other problem happened .
java.lang.StackOverflowError: stack size 8192KB
Even I test a 3items list .
I'm so disapointed.

You created an endless loop...
What about providing a screenshot of your relevant blocks?

Make sure to use the latest version of the companion app...


Perhaps use this algorithm by Sajal to sort your List if you have to because you cannot use the new List tools:
* List Sorting On App Inventor

Before you give up on the new List tools, follow Taifun's advice. It will help us understand the problem and possibly provide a solution. Better yet, provide a sample aia?

Thanks a lot。
I have write a function to sort my list.
It's much faster than I thought 。

you are right , while exchange the 2 items in the list , a list was given to replace a item ,
so the list get’s
biger and biger。
finally ,It works 。

Attached is a sample table sort by column 2, using the new sort block in nb191, on the latest MIT emulator.

Get the new emulator:

One dimensional sorting works there:
scalar sort

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.