Sorting a list of positive and negative integers

Report a typo

Given a space separated list of integers, sort the list in ascending order and output the sorted list with each number followed by a space. The program should be capable of sorting both positive and negative numbers.

Sample Input 1:

3 -4 2 7 -1

Sample Output 1:

-4 -1 2 3 7 

Sample Input 2:

10 2 8 4 6

Sample Output 2:

2 4 6 8 10 
Write a program in Kotlin
import java.util.*

fun main(args: Array<String>) {
// Create a mutable list to store the input numbers
val numberList = mutableListOf<Int>()

// Use a scanner to read the user input
val scanner = Scanner(System.`in`)

// TODO: Extract the integers from the input and add them to the mutable list

// TODO: Sort the list in ascending order

// TODO: Iterate through the sorted list and print each number followed by a space.
}
___

Create a free account to access the full topic