[B4X][LOA] ListOfArrays - lightweight, powerful and flexible collection
ListOfArrays (LOA) is a simple list where each item is an array of objects, and each array represents a row. As LOA stores tabular data, all rows have the same length. LOA is lightweight and a list can be converted to a LOA and vice versa, with (almost) no overhead. It is loosely inspired by...
Task: count the number of occurrences of each English letter in this list, with 370K words: https://github.com/dwyl/english-words/blob/master/words_alpha.txt
The output should be a list with the letters, sorted by the number of occurrences.
B4X:
Log(SortedLetters)
I've implemented it in two ways. The first is straightforward and robust and the second is more optimized.
Testing with B4J in release mode, the first method takes ~200ms and the second ~25ms.