static L pixelsByBrightness(IBWImage image) { float[] data = image.toFloatArray(); int n = l(data); int[] indices = new[n]; for i to n: indices[i] = i; timSortIntArrayWithComparator(indices, (i, j) -> cmp(data[i], data[j])); int w = image.w(); ret listFromFunction(n, i -> ptFromPixelIndex(indices[i], w)); }