Sorting algorithm implementations in Java