I'm using a cachedrowset to store data from the database... I wanted to sort the data in the cachedrowset by a particular field. Say I have queried the data resulting to 10 columns and eventually stored in a cachedrowset. I wanted to sort it for example by column 1 or column 3 or any column without reconnecting again to the database. How am I going to do that?
I think you will have to parse out the results into memory, either into VO's that corresponds to the objects being brought back, or maybe even something as simple as a arraylists, a new instance for each row. You can then run a sorting algorithm on these, and store in something like a sorted list.
I agree that it is good to use an ArrayList of value objects (beans with get and set methods.) Also, keep in mind that Java has a sort method. So all you have to do is write a Comparator that sorts on the correct field number and call Collections.sort(). It's much easier than writing your own sort algorithm.