Sunday, June 30, 2013

[android help] Sorting items from an array of arrays


Sorting items from an array of arrays



I have a multidimensional array of dates, strictly an ArrayList>. I need to generate a new single-dimensional ArrayList made up of the items in all the arrays of the previously mentioned multidimensional one.


My first thought was to join all the arraylists together and sort them, but since I don't know the number of elements in each level, and only need a certain number of elements in the generated array, that would be a bit too much memory-and-processor-heavy. I mean, if I join all the Date elements in one ArrayList, I might end up with an arraylist of thousands of dates... to just eventually trim it to the first 20. That's why I dropped that solution.


So, which algorithm could I use to sort elements from N (or 2) levels into 1?



.

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...