Re: How to sort a multidimensional ndslice?

2020-08-19 Thread 9il via Digitalmars-d-learn
On Tuesday, 18 August 2020 at 13:07:56 UTC, Arredondo wrote: On Tuesday, 18 August 2020 at 04:07:56 UTC, 9il wrote: To reorder the columns data according to precomputed index: auto index = a.byDim!1.map!sum.slice; Hello Ilya, thanks for the answer! Unfortunately I can't use it because I

Re: How to sort a multidimensional ndslice?

2020-08-18 Thread James Blachly via Digitalmars-d-learn
On Tuesday, 18 August 2020 at 13:07:56 UTC, Arredondo wrote: On Tuesday, 18 August 2020 at 04:07:56 UTC, 9il wrote: To reorder the columns data according to precomputed index: auto index = a.byDim!1.map!sum.slice; Hello Ilya, thanks for the answer! Unfortunately I can't use it because I

Re: How to sort a multidimensional ndslice?

2020-08-18 Thread Arredondo via Digitalmars-d-learn
On Tuesday, 18 August 2020 at 04:07:56 UTC, 9il wrote: To reorder the columns data according to precomputed index: auto index = a.byDim!1.map!sum.slice; Hello Ilya, thanks for the answer! Unfortunately I can't use it because I don't have (and can't define) a sorting index for my columns. I

Re: How to sort a multidimensional ndslice?

2020-08-17 Thread 9il via Digitalmars-d-learn
The following code just sorts each row: -- /+dub.sdl: dependency "mir-algorithm" version="~>3.9.24" +/ import mir.ndslice; import mir.ndslice.sorting; import mir.algorithm.iteration: each; void main() { // fuse, not sliced if you use an array of arrays for argument auto a = [[1,

How to sort a multidimensional ndslice?

2020-08-17 Thread Arredondo via Digitalmars-d-learn
I want to sort a two-dimensional ndslice by its columns according to some predefined predicate. What I mean is _not_ sorting the contents of each column individually, but instead to reorder the entire columns of the matrix so that they are sorted according to some "greater than" function.