/help
I have an array of Pairs.
The first value in the Pair represents coefficient of a polynomial, and the second represents the power of the polynomial.
How can I sort it in a descending order without creating a long code?
Someone here recommended me to use Collections.sort() on the array of Pairs, but I don't understand how it's possible to do this on this array, since it doesn't represent a list, so it's impossible to sort it.
I obviously need to sort it by the powers value, but how it's possible to do this and change the coefficient's indices in accordance with the power parameter?
Thank you!
10 Replies
⌛
This post has been reserved for your question.
Hey @Yarden! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
Yes exactly
I'm trying for so long to find a solution but didn't find anything about it
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
I already put inside the Pairts the 2 different arrays, now everything is mixed up and I need to sort them
Exactly
Pairs = [[7,3], [5,4], [8,6], [9,2]]
it looks something like this
I need to sort it to be like this:
Pairs = [[8,6], [5,4], [7,3 ], [9,2]]
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
something like this?
_polynomial is the ArrayList of Pairs
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
I'm sorry, I wasn't home for few hours, I'll save it and try to finish it tomorrow.
I'll sit the whole day tomorrow to do this
Thank you very much ❤️
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.