Question: this is java problem SORTED so you have arraylist ArrayList numbers = {-15,-10,-20,-2,0,10,2,3,4,5} this list are not sorted we need to make it sorted using

this is java problem SORTED

so you have arraylist

ArrayList numbers = {-15,-10,-20,-2,0,10,2,3,4,5}

this list are not sorted we need to make it sorted using two method

first medthod call ifNegative that implement Comparator Interface the method parameter with numbers but

need to take only negative number and order it from the biggest number to smallest for example in this case.

-2, -10, -15, -20

sercond medthod is ifPositive that implement Comparator Interface the method with parameter numbers but

need to take only positive number and need to order it from smallest to biggest (normal ordering)

in this case 0,2,3,4,5,10

and in the end they need to be order as is in the arraylist that we have so this special sort should be

-2, -10, -15, -20,0 ,2, 3, 4, 5, 10

we can use

Collections.sort(numbers, new ifpositive())

,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!