Question: hi I have results from a strategy I am running in the following format:

```none
2013-12-27 00:00:00: {'SPX': 1841.4, 'SPTR': 3302.66, ..., 'prev_day_rate': 0.08}
...
2015-12-27 00:00:00: {'SPX': 1841.4, 'SPTR': 3302.66,..., 'prev_day_rate': 0.08}

```

I transform it into a DataFrame and copy to excel but the rendering is all over the place and not something I can work with (because it is a dictionary?)

What are the steps to make the output more user friendly?

thanks

Answer: 
Optimal compared to what other solution? You are sorting a two dimensional array and supplying a Comparator to govern the sort. `Arrays.sort` implements an efficient, stable sorting algorithm. I would use it but I would specify the comparator as follows:

```
Arrays.sort(points, Comparator.comparingInt((int[] a) -> a[0])
            .thenComparingInt(a -> a[1]));

```

Subtracting elements to adhere to the requirements of the Comparator is not a good practice and can result in improperly sorted data structures when the values are near `Integer.MAX_VALUE` and `Integer.MIN_VALUE`.
You can use the *comparator chaining* as follows:

```java
int[][] points;
// sorting the rows of a 2d array first by the
// first column and then by the second column
Arrays.sort(points, Comparator
        .<int[], Integer>comparing(arr -> arr[0])
        .thenComparing(arr -> arr[1]));

```

---

See also: [Sorting a 2d array in Java](https://stackoverflow.com/a/67181501/15933560)