[java] How to sort ArrayList<Long> in decreasing order?

So, There is something I would like to bring up which I think is important and I think that you should consider. runtime and memory. Say you have a list and want to sort it, well you can, there is a built in sort or you could develop your own. Then you say, want to reverse the list. That is the answer which is listed above.

If you are creating that list though, it might be good to use a different datastructure to store it and then just dump it into an array.

Heaps do just this. You filter in data, and it will handle everything, then you can pop everything off of the object and it would be sorted.

Another option would be to understand how maps work. A lot of times, a Map or HashMap as something things are called, have an underlying concept behind it.

For example.... you feed in a bunch of key-value pairs where the key is the long, and when you add all the elements, you can do: .keys and it would return to you a sorted list automatically.

It depends on how you process the data prior as to how i think you should continue with your sorting and subsequent reverses