Java's Arrays.asList quirk
Recently, I was working on an program that used arrays heavily. Since I’m lazy and I needed to sort the array, I converted the array to a list in order to use the built-in functions.
Since the pixels are now conveniently in a list, I can sort them every which way I want.
The results weren’t quite what I expected. This is because of a very important line of text in the Java API:
Returns a fixed-size list **backed by the specified array**.
This means that if you sort the list, the array will be sorted as well. Luckily this is easy to fix - just copy the array before you create a list from it: