I'm needing to be able to sort an Array Class that I've created that holds over 300,000 or even sometimes 1,000,000 results on an Android Phone.
However I want it to be quicker so I have been looking into possible options such as a Merge Sort or a parallel sort, but these are mostly dealing with arrays with just integers in a single line (from left to right) in order to sort.
Here is an example of my currently Array Class...
public class ClassSearchResults {
private int rowID;
private String TitleHREF;
private String ImageSRC;
private String Title;
private int Price;
public int getRowID() {
return rowID;
}
public void setRowID(int rowID) {
this.rowID = rowID;
}
public String getTitleHREF() {
return TitleHREF;
}
public void setTitleHREF(String TitleHREF) {
this.TitleHREF = TitleHREF;
}
public String getImageSRC() {
return ImageSRC;
}
public void setImageSRC(String ImageSRC) {
this.ImageSRC = ImageSRC;
}
public String getTitle() {
return Title;
}
public void setTitle(String Title) {
this.Title = Title;
}
public int getPrice() {
return Price;
}
public void setPrice(int Price) {
this.Price = Price;
}
Now I am wanting to be able to sort this by the getPrice field of course. The methods I have tried are doing a regular Comparitor / Collections.sort but after sooo many records this seems to be very very slow overall and I run into out of memory issues.
Is there any better ways of doing this? Should I even be using an array class or should I be using something else?
Should I just create a local SQL Database and throw the results in there first then sort and output?
I'm looking for the BEST, FASTEST, and most Stable way of doing this. Keep in mind that we are looking for OVERALL speed for Inserting/Cataloging the Result, then Sorting the Result, then Outputing it in a system.out.println or some type of simple output.
If I should be using a whole different data structure, what should I be using?