/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
JavaBot
JavaBot12mo ago
This post has been reserved for your question.
Hey @Yarden! Please use /close or the Close 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP12mo ago
Yes exactly I'm trying for so long to find a solution but didn't find anything about it
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP12mo ago
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
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP12mo ago
something like this? _polynomial is the ArrayList of Pairs
No description
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP12mo ago
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 ❤️
JavaBot
JavaBot12mo ago
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.
Want results from more Discord servers?
Add your server