File tree Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Original file line number Diff line number Diff line change 1
1
package travelator
2
2
3
- import travelator.Collections.sorted
4
3
import travelator.Other.SOME_COMPLICATED_RESULT
5
- import java.util.Comparator.comparing
6
4
import java.util.stream.Collectors
7
5
8
6
object Suffering {
@@ -15,16 +13,8 @@ object Suffering {
15
13
}
16
14
17
15
@JvmStatic
18
- fun longestJourneysIn (
19
- journeys : List <Journey >,
20
- limit : Int
21
- ): List <Journey > {
22
- val actualLimit = Math .min(journeys.size, limit)
23
- return sorted(
24
- journeys,
25
- comparing { obj: Journey -> obj.duration }.reversed()
26
- ).subList(0 , actualLimit)
27
- }
16
+ fun longestJourneysIn (journeys : List <Journey >, limit : Int ): List <Journey > =
17
+ journeys.sortedByDescending { it.duration }.take(limit)
28
18
29
19
fun routesToShowFor (itineraryId : String? ): List <List <Journey >> {
30
20
return bearable(Other .routesFor(itineraryId))
You can’t perform that action at this time.
0 commit comments