public void sort(ArrayList<Integer> arr) {
        timeOfSorting = System.currentTimeMillis();
        Random rnd = new Random();
        while(true) {
            boolean sorted = true;
            for (int i = 0; i < arr.size()-1; i++) {
                compare_count++;
                if(arr.get(i) > arr.get(i+1)){
                    sorted = false;
                    break;
                }
            }
            if (sorted) {
                break;
            }
            for (int i = arr.size() - 1; i > 0; i--) {
                int rand = rnd.nextInt(i);
                insert_count++;
                int tmp = arr.get(i);
                arr.set(i, arr.get(rand));
                arr.set(rand, tmp);
            }
        }
        timeOfSorting = System.currentTimeMillis() - timeOfSorting;
    }