A
A
Al Tinho2020-06-15 14:48:25
Java
Al Tinho, 2020-06-15 14:48:25

How to solve a problem in Kotlin?

Hello!
There is a multiline text like this:

6 need 10 GiB Tue May 12 10:14:09 2020 10 GiB Tue May 12 10:14:09 2020 1
gitlab-database-2020-05-12-10-00-00
25 21:59:59 2020
3 gitlab-database-2020-05-12-10-00-00 10 GiB Tue May 12 10:14:09 2020
4 gitlab-database-2020-05-12-10-00-00 10 GiB Tue May 12 10:14:09 2020
5 gitlab-
database-2020-05-12-10-00-00 -00-00 10 GiB Tue May 12 10:14:09 2020

9 2020-05-20-19-00-00 10 GiB Wed May 20 19:49:22 2020

11 2020-05-25-hjhhjbg 10 GiB Mon May 25 21:59:59 2020

The task in kotlin is to sort by the 1st column and display the 2nd column, without the last five lines, tell me at least an idea how to do it, I recently began to study kotlin ....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2020-06-15
@alex_terekhov

1) Split into lines (split)
2) Parse each line with a regular expression (regexp) and add it to an object with two fields (first and second)
3) Sort the list of objects (sort)
4) Take the required number of objects from the list (take / drop)
...
Profit!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question