Implementing Java sorts