sort float array Asc - Android java.lang

Android examples for java.lang:array sort

Description

sort float array Asc

Demo Code


//package com.java2s;

public class Main {
    public static float[] sortAsc(float[] src) {
        if (src == null)
            return null;
        int len = src.length;
        int i, j, k;
        for (i = 0; i < len; i++) {
            k = i;//from  ww w .  j a  v  a  2s .co m
            for (j = i + 1; j < len; j++) {
                if (src[k] > src[j])
                    k = j;
            }
            if (i != k) {
                float tmp;
                tmp = src[i];
                src[i] = src[k];
                src[k] = tmp;
            }
        }
        return src;
    }
}

Related Tutorials