'bottommost row'. Note that Python's bools can be # evaluated as integers; True == 1 and False == 0. return_list.append(sum(n > i for n in transposed_list)) # The resulting list is sorted in descending order return return_list We can also implement the algorithm using Java. public static void beadSort(int[] a) { // Find the maximum element int max = a[0]; for (int i = 1; i < a.length; i++) { if (a[i] > max) { max = a[i]; } } // allocating memory int[][] beads = new int[a.length][max]; // mark the beads for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i]; j++) { beads[i][j] = 1; } } // move down the beads for (int j = 0; j < max; j++) { int sum = 0; for (int i = 0; i < a.length; i++) { sum += beads[i][j]; beads[i][j] = 0; } for (int i = a.length - 1; i >= a.length - sum; i--) { a[i] = j + 1; } } } Notes References External links Bead Sort in MGS, a visualization of a bead sort implemented in the MGS programming language Bead Sort on MathWorld Bead Sort interactive visualization Sorting algorithms 2002 in computing