I thought it worked like that:
take 2 numbers from array (i and i+1),
if i<i+1 replace them (so they should be in order: i+1 and then i).
but the method shows numbers without any order :(
package pl.codegym.task.task07.task0728;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
W kolejności malejącej
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int[] tablica = new int[20];
for (int i = 0; i < 20; i++) {
tablica[i] = Integer.parseInt(reader.readLine());
}
sortuj(tablica);
for (int x : tablica) {
System.out.println(x);
}
}
public static void sortuj(int[] tablica)
{
for(int i=0; i<tablica.length; i++)
{
if(i + 1 == tablica.length)
{
break;
}
if (tablica[i]<tablica[i+1])
{
int a = tablica[i];
int b = tablica[i+1];
tablica[i+1]=a;
tablica[i]=b;
}
}
}
}