CodeGym /Courses /Java Multithreading /Practice with sorting and using Comparator

Practice with sorting and using Comparator

Java Multithreading
Level 6 , Lesson 2
Available

"Hi, Amigo!"

28
Task
Java Multithreading, level 6, lesson 2
Locked
Read online about the median of a sample
Implement the logic of the sort() method. It must sort the data in the array according to its distance from the median. Return the array sorted from the least to greatest distance. If several numbers are equally distant, then sort them in ascending order.
8
Task
Java Multithreading, level 6, lesson 2
Locked
Think and you will succeed
Soldiers have always assembled, do assemble, and will assemble by descending height. After thinking about whether it would be better to use Comparable or Comparator for this task, sort the soldiers.
14
Task
Java Multithreading, level 6, lesson 2
Locked
A convert can easily convert others
A table has columns that can be sorted. The user can customize the list of columns that will be sorted. Write a public static Comparator CustomizedComparator that will: 1. take an array of comparators via the constructor. 2. sort data in the order that corresponds to the sequence of comparators.
Comments (6)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Максим Василенко Level 44, Kiev, Ukraine
29 January 2023
what??? you must use "..." and can't use "[]". why??? (last task)
Максим Василенко Level 44, Kiev, Ukraine
29 January 2023
Can't understand what Codegym want from me at last task.
Maria Level 34, Utrecht, Netherlands
1 November 2020
If a class has obvious natural sorting logic (0-10, a - z), then it is better to use Comparable, in other cases Comparator
Ewerton Level 30, Belo Horizonte, Brasil
13 July 2019
- "Think about which is best to use, and then implement Comparable or Comparator". - Ok, I wrote a one-line solution using comparator. - WRONG, "Be sure that the Soldier class implements the Comparable interface". ...
Vahan Level 41, Tbilisi, Georgia
12 March 2020
cause after that they required compareTo method ))
Andrei Level 41
30 April 2021
lmao epic trolling 😂