/**
 * Program Name: SortingAlgorithms.java
 */


package wdcor;
//import wdcor.WorldCoords;

public class SortingAlgorithms {
	
	
	/**
	 * Here I've implemented the insertion sort
	 * @param X the array to be sorted
	 * @param C the comparator
	 */
	public static void mySortingAlgorithm(WorldCoords[] X, WorldCoordsComparator C){
		
		for(int right = 1; right < X.length; right++)
			for(int j = right; j > 0; j--){
				if(C.isLessThan(X[j], X[j-1]))
					swap(X, j, j-1);
				else
					break;
			}
		
	}
	
	/**
	 * swaps two objects in the array by their specified locations
	 * @param X the array
	 * @param i location 1
	 * @param j location 2
	 */
	public static void swap(WorldCoords[] X, int i, int j){
		WorldCoords temp = X[i];
		X[i] = X[j];
		X[j] = temp;
	}


}
