Sort the odd(codewars-java)

You have an array of numbers.

Your task is to sort ascending odd numbers but even numbers must be on their places.

Zero isn't an odd number and you don't need to move it. If you have an empty array, you need to return it.



public class Kata {

  public static int[] sortArray(int[] array) {

  int min=0;

    for(int i =0;i

        if(array[i]%2==0){

        }else {

            for(int j=i;j

                if(array[j]%2==0){

                }else{

                    if(array[i]>array[j]){

                        min=array[j];

                        array[j]=array[i];

                        array[i]=min;

                    }

                }

            }

        }

        return array;

  }

}

你可能感兴趣的:(Sort the odd(codewars-java))