sorting a ublas matrix

#include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/io.hpp> using namespace boost::numeric::ublas; matrix<MyObject> m_MyObjects(nRows, nCols); I have a ublas matrix of objects as declared above... Is there a way within the Boost lib (i.e. something I don't have to write much custom code to use) that I can use to sort the matrix by a value of one of the data members of MyObject? For example If class MyObject { int thisOne; } and m_MyObjects(0,0).thisOne = 1; m_MyObjects(1,0).thisOne = 0; m_MyObjects(0,1).thisOne = 4; m_MyObjects(1,1).thisOne = 2; It will sort the matrix so that m_MyObjects(0,0).thisOne = 0; m_MyObjects(1,0).thisOne = 1; m_MyObjects(0,1).thisOne = 2; m_MyObjects(1,1).thisOne = 4; Ed

AMDG Ed wrote:
#include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/io.hpp> using namespace boost::numeric::ublas;
matrix<MyObject> m_MyObjects(nRows, nCols);
I have a ublas matrix of objects as declared above... Is there a way within the Boost lib (i.e. something I don't have to write much custom code to use) that I can use to sort the matrix by a value of one of the data members of MyObject? For example
std::sort(m_MyObjects.data().begin(), m_MyObjects.data().end(), /appropriate predicate/); In Christ, Steven Watanabe
participants (2)
-
Ed
-
Steven Watanabe