Sort The Absolute List

easy
1. You are given a linked list, sorted in ascending order
         based on the absolute values of its data.
      2. You have to sort the linked list according to the actual values.
      3. Node class represents the node of Linked List.
      4. display is a utility function which displays the contents of Linked List,
         feel free to use it for debugging purposes.
      5. main takes input from the users and creates the Linked List. You can use
         display to know its contents.
      6. This is a functional problem. 
      7. You should code only the sort function, feel free to change its
         signature if required. It should return the head of the linked list.
      8. Don't change the code of Node, main and display.

Input Format

First line takes N, the number of elements in the list. Next line takes input N space separated integers. Input is handled for you.

Output Format

N space separated integers sorted according to actual values. Input is handled for you.

Constraints

1 <= N <= 100
      -100 <= L[i] <= 100

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
6
-17 18 28 -32 34 64
Output
-32 -17 18 28 34 64
Previous
Circular Linked List
Next
Decimal Number From Binary Linked List

Related Questions