[
https://issues.apache.org/jira/browse/NUMBERS-164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17364898#comment-17364898
]
Alex Herbert commented on NUMBERS-164:
--------------------------------------
I would just change to this:
{code:java}
/** Sort in ascending order. */
ASCENDING((o1, o2) -> Double.compare(o1.key(), o2.key())),
/** Sort in descending order. */
DESCENDING((o2, o1) -> Double.compare(o1.key(), o2.key()));
{code}
The {{comparator.reversed()}} ends up doing the same but you will have more
dereferencing required by the extra layer of a comparator wrapper.
> Port "sortInPlace" from Commons Math
> ------------------------------------
>
> Key: NUMBERS-164
> URL: https://issues.apache.org/jira/browse/NUMBERS-164
> Project: Commons Numbers
> Issue Type: Task
> Components: arrays
> Reporter: Gilles Sadowski
> Assignee: Gilles Sadowski
> Priority: Minor
> Labels: api, port
> Fix For: 1.0
>
>
> Method is currently in utility class
> [{{MathArrays}}|https://gitbox.apache.org/repos/asf?p=commons-math.git;a=blob;f=commons-math-legacy-core/src/main/java/org/apache/commons/math4/legacy/core/MathArrays.java;h=10a8ed15c848c0da08fc92bfd72907dd75d9cd47;hb=HEAD#l612].
> Proposed API:
> {code}
> public enum Sort implements BiConsumer<double[],double[][]> {
> /** Sort in ascending order. */
> ASCENDING((o1, o2) -> Double.compare(o1.key(), o2.key())),
> /** Sort in descending order. */
> DESCENDING(ASCENDING.comparator.reversed());
> // ...
> @Override
> public void accept(double[] x,
> double[]... yList) {
> // ...
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)