TORONTO KIDS COMPUTER CLUB | PMCA Sunday 12:00 Java Homework 20.07.26.
18052
post-template-default,single,single-post,postid-18052,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

PMCA Sunday 12:00 Java Homework 20.07.26.

01 Aug PMCA Sunday 12:00 Java Homework 20.07.26.

Question:
Write code to do absolute sort with the following condition

    1.  Sort an array according to its absolute value. Please refer to this link https://en.wikipedia.org/wiki/Absolute_value if you don’t know what absolute value is
    2. If the array for a specific number contains both its negative form and the positive form, the sorting algorithm should put the negative form of the number before the positive form
Input
[1,2,3 -2, 0 , -1, -2,  4]

Output
[ 0, -1, 1, -2, -2, 2, 3, 4]
No Comments

Sorry, the comment form is closed at this time.