You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zanninso db990087bf
docs: adding subjects for quest 5 of the java piscine (#2062)
1 year ago
..
README.md docs: adding subjects for quest 5 of the java piscine (#2062) 1 year ago

README.md

SortList

Instructions

Create a file Sort.java.

Write a function sort that returns the ascending sorted list as parameter.
Write a function sortReverse that returns the descending sorted list as parameter.

Expected Functions

import java.util.List;

public class Sort {

    public static List<Integer> sort(List<Integer> list) {
        // your code here
    }

    public static List<Integer> sortReverse(List<Integer> list) {
        // your code here
    }
}

Usage

Here is a possible ExerciseRunner.java to test your function :

import java.util.List;

public class ExerciseRunner {

    public static void main(String[] args) {
        System.out.println(Sort.sort(List.of(15, 1, 14, 18, 14, 98, 54, -1, 12)).toString());
        System.out.println(Sort.sortReverse(List.of(15, 1, 14, 18, 14, 98, 54, -1, 12)).toString());
    }
}

and its output :

$ javac *.java -d build
$ java -cp build ExerciseRunner 
[-1, 1, 12, 14, 14, 15, 18, 54, 98]
[98, 54, 18, 15, 14, 14, 12, 1, -1]
$ 

Notions

List