Open
Description
For a project I'm working on, I wrote a function that sorts a 2d matrix by the values in a particular column. Wanted to see if you were interested in generalizing this for ndarray (e.g. sort by row value, n-dimensional sorting etc).
pub fn sort_matrix(mat : Mat<f64>, sort_col: ArrayView<f64,Ix>) -> Mat<f64>{
let mut enum_col = sort_col.iter().enumerate().collect::<Vec<(usize, &f64)>>();
enum_col.sort_by(|a, &b| a.1.partial_cmp(b.1).unwrap());
let indices = enum_col.iter().map(|x| x.0).collect::<Vec<usize>>();
mat.select(Axis(0), indices.as_slice())
}