All pastes #2116593 Raw Edit

Anonymous

public java v1 · immutable
#2116593 ·published 2012-02-10 16:39 UTC
rendered paste body
	public void sortByFour(){	    if(_arr!=null){	        int oIx = 0;	        int current = 0;	        int twoIx = _arr.length-1;	        int threeIx = twoIx;	        while(current <= twoIx){	           switch (_arr[current] % 4){	               case 0: swap (current, oIx);	                       current++;	                       oIx++;	                       break;	                       	               case 1: current++;	                       break;	                       	               case 2: swap(current, twoIx);	                       twoIx--;	                       break;	                       	               case 3: swap(twoIx, current);	                       swap(twoIx, threeIx);	                       twoIx--;	                       threeIx--;	                       break;	           }	        }	    }	}		private void swap(int a,int b){	    if(_arr!=null && a<_arr.length && b<_arr.length){	        int tmp = _arr[a];	        _arr[a] = _arr[b];	        _arr[b] = tmp;	       }	}