package edu.isi.karma.modeling.semantictypes.myutils;

import java.util.ArrayList;

public class ListOps {

	// Sorts values in descending order
	// Rearranges the list so that the objects are at the same index as their corresponding values
	// So, the item that had highest corresponding score will be at position zero and
	// item with the lowest score will be at the end of the list
	public static void sortListOnValues(ArrayList list, ArrayList<Double> values) {
		int pos = 0 ;
		
		for(int i=0;i<list.size()-1;i++) {
			pos = i ;
			for(int j=i+1;j<list.size();j++) {
				if(values.get(j) > values.get(pos)) {
					pos = j ;
				}
			}
			double maxVal = values.get(pos) ;
			values.set(pos, values.get(i)) ;
			values.set(i, maxVal) ;
			
			Object obj = list.get(pos) ;
			list.set(pos, list.get(i)) ;
			list.set(i, obj) ;
		}
	}
	
	
}

@@ -212,16 +212,20 @@
 as their
+%0A%09//
  corresp
@@ -311,16 +311,20 @@
 position
+%0A%09//
  zero an
@@ -401,16 +401,20 @@
 c static
+ %3CT%3E
  void so
@@ -441,15 +441,21 @@
 List
+%3CT%3E
  list,
- 
+%0A%09%09%09
 Arra
@@ -495,30 +495,33 @@
  = 0
- 
 ;%0A
-%09%09
 %0A%09%09for
+ 
 (int i
-=0;i%3C
+ = 0; i %3C 
 list
@@ -531,11 +531,14 @@
 ze()
--
+ - 
 1;
+ 
 i++)
@@ -554,17 +554,16 @@
  = i
- 
 ;%0A%09%09%09for
 (int
@@ -562,21 +562,29 @@
 %09for
+ 
 (int j
-=i+1;j%3C
+ = i + 1; j %3C 
 list
@@ -591,16 +591,17 @@
 .size();
+ 
 j++) %7B%0A%09
@@ -605,16 +605,17 @@
 %7B%0A%09%09%09%09if
+ 
 (values.
@@ -654,17 +654,16 @@
 %09pos = j
- 
 ;%0A%09%09%09%09%7D%0A
@@ -697,25 +697,24 @@
 ues.get(pos)
- 
 ;%0A%09%09%09values.
@@ -732,25 +732,24 @@
 lues.get(i))
- 
 ;%0A%09%09%09values.
@@ -766,24 +766,15 @@
 Val)
- 
 ;%0A
-%09%09%09
 %0A%09%09%09
-Object
+T
  obj
@@ -789,17 +789,16 @@
 get(pos)
- 
 ;%0A%09%09%09lis
@@ -820,17 +820,16 @@
 .get(i))
- 
 ;%0A%09%09%09lis
@@ -841,17 +841,16 @@
 (i, obj)
- 
 ;%0A%09%09%7D%0A%09%7D
@@ -854,10 +854,7 @@
 %0A%09%7D%0A
-%09%0A%09
 %0A%7D%0A

Fix warning.