Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Sorting an ArrayList without using Collections.sort

807588Apr 19 2009 — edited Apr 19 2009
I'm trying to sort information in an ArrayList.
Basically, it removes the information if the data is >= to 0.5 (as it's faulty data)

and with all the remaining data, it sorts them in order.
How would I sort it?

I'm thinking of using some kind of recursion, creating a copy of the datalist
and then as I compare it with the original adding them, but this is just a thought...

Thanks!

   private static ArrayList sortInOrder(ArrayList datalist, String url) 
   {
	  
	  for (int i = 0; i < datalist.size(); i++)
	  {
		  SensorData data = (SensorData)datalist.get(i);
		  if(data.getSwellWaveHeight() >= 0.5)
		  {
			  datalist.remove(i);
		  }
		  else
		  {
			  data = datalist.sort(datalist);
		  }
		  
	  }
	  return datalist;
	  
   }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2009
Added on Apr 19 2009
26 comments
2,926 views