Java Array Sort sort(int[] intValues)

Here you can find the source of sort(int[] intValues)

Description

sort

License

Open Source License

Declaration

public static void sort(int[] intValues) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * //from   w  w  w .j  a v a  2s .c  o m
 * Contributors:
 *     Nokia Corporation - initial implementation 
 *******************************************************************************/

public class Main {
    public static void sort(int[] intValues) {
        int idxs[] = intValues;
        int length = idxs.length;
        for (int gap = length / 2; gap > 0; gap /= 2) {
            for (int i = gap; i < length; i++) {
                for (int j = i - gap; j >= 0; j -= gap) {
                    if (idxs[j] > idxs[j + gap]) {
                        int swap = idxs[j];
                        idxs[j] = idxs[j + gap];
                        idxs[j + gap] = swap;
                    }
                }
            }
        }
    }
}

Related

  1. sort(int[] array)
  2. sort(int[] array)
  3. sort(int[] asd)
  4. sort(int[] idxs, double[] values)
  5. Sort(int[] in)
  6. sort(int[] keys, int[] values)
  7. sort(int[] values)
  8. sort(Number[] array)
  9. sort(O[] array)