package org.rut.util.algorithm.support; |
import org.rut.util.algorithm.SortUtil; |
/** |
* @author treeroot |
* @since 2006-2-2 |
* @version 1.0 |
*/ |
public class InsertSort implements SortUtil.Sort{ |
/* (non-Javadoc) |
* @see org.rut.util.algorithm.SortUtil.Sort#sort(int[]) |
*/ |
public void sort( int [] data) { |
int temp; |
for ( int i= 1 ;i<data.length;i++){ |
for ( int j=i;(j> 0 )&&(data[j]<data[j- 1 ]);j--){ |
SortUtil.swap(data,j,j- 1 ); |
} |
} |
} |
} |