I'm trying to make a bubble sorting algorithm in Java however my code just keeps going when It's supposed to sort without returning anything. When the program is run it gets as far as printing the array before the sorting however after that nothing happens but the program doesnt stop it keeps running

```
package src;
import java.util.Scanner;
import java.util.Random;
import java.util.ArrayList;
import java.util.List;

public class bubbleSort {

    public static void main(String[] args) {

        int length = getLength();

        List<Integer> randomList = createList(length);

        System.out.println("The list before sorting:\n" + randomList);

        List<Integer> newList = sortList(randomList, length);

        System.out.println("The list after sorting:\n" + newList);

    }

    public static int getLength() {
        System.out.println("Please enter how long you want the array to be");

        Scanner reader = new Scanner(System.in);

        int length = Integer.parseInt(reader.nextLine());

        return length;
    }

    public static List<Integer> createList(int length) {
        Random rand = new Random();

        List<Integer> randomList = new ArrayList<Integer>();

        for(int x = 0 ; x < length ; x++){
            int randomnumber = rand.nextInt((100 - 1) + 1) + 1;
            randomList.add(randomnumber);
        }

        return randomList;  
    }

    public static List<Integer> sortList(List<Integer> randomList, int length){
        boolean sorted = false;

        while(sorted == false){
            sorted = true;

            for(int x = 0 ; x < (length - 1) ; x++) {
                if(randomList.get(x) > randomList.get(x + 1)) {
                    sorted = false;
                    int temp = randomList.get(x + 1);
                    randomList.set((x + 1), (x));
                    randomList.set((x + 1), temp);
                }
            }
        }

        return randomList;
    }

}

```