I'm having trouble explaining what I am looking for so I will provide an example, let's say I have this array:

```
[
  [1, 2],
  [1, 3],
  [1, 4],
  [2, 3],
  [2, 4],
  [3, 4]
]

```

rather than sorting it by the first column, I would like it to cycle through the first column, so instead of `1, 1, 1, 2, 2, 3` it would do: `1, 2, 3, 1, 2, 1`

resulting in:

```
[
  [1, 2],
  [2, 3],
  [3, 4],
  [1, 3],
  [2, 4],
  [1, 4]
]

```

Even better would be if it could cycle through both columns to prevent two numbers in a row as much as possible, the ideal solution would sort the original array as:

```
[
  [1, 2],
  [3, 4],
  [1, 3],
  [2, 4],
  [1, 4],
  [2, 3]
]

```

Leading to the maximum spacing between repeating numbers for each inner array (both columns being taken into account).

I hope I have provided sufficient information, and I will greatly appreciate any advise, I am fairly clueless so far, searching has yeilded me nothing.