- Jun 6, 2020
- 11,559
- 4,422
In B4X it is easy to sort a List in any arbitrary way, thanks to the fact that we can simply pass the name of a function anywhere.
I am using a non-recursive search here, because I had to sort lists with hundreds of thousands of items. The sorting is quite fast, good enough for sure. B4J is fast!
The name of the function is ListSort, not "SortList", because you may have other ListXxxx utility functions, and this way code completion will show all of them under "List", so it is easier to find them.
This function "lives" in a static code module in my case. It is natural that we must pass the List instance to it, but the second parameter is "Context". Why?
In B4X, you can pass the name of a function to another function, and use it like this:
A function to call:
The AnObject parameter is a class that implements the function. If you want to have a function in...
I am using a non-recursive search here, because I had to sort lists with hundreds of thousands of items. The sorting is quite fast, good enough for sure. B4J is fast!
The name of the function is ListSort, not "SortList", because you may have other ListXxxx utility functions, and this way code completion will show all of them under "List", so it is easier to find them.
This function "lives" in a static code module in my case. It is natural that we must pass the List instance to it, but the second parameter is "Context". Why?
In B4X, you can pass the name of a function to another function, and use it like this:
A function to call:
کد:
محتوای بلوک کدها در دسترس شما نیست. برای مشاهده بلوک کدها، وارد انجمن شوید یاثبت نام کنید
The AnObject parameter is a class that implements the function. If you want to have a function in...
برای دیدن لینک ها باید ثبت نام کنید
برای دیدن لینک ها باید ثبت نام کنید