Sort columns by row content.
int SortColumns( SortColCtrl* pCtrls, int nCtrlSize, int c1 = 0, int c2 = -1, BOOL bUndo = FALSE )
Returns 0 on successful exit and negative number on error.
EX1
void SortColumns_by_label_ex() { Worksheet wks = Project.ActiveLayer(); if(!wks) return; vector<int> vnLabelTypes = {RCLT_LONG_NAME, RCLT_PARAM}; int nSize = vnLabelTypes.GetSize(); //number of Sort Criteria int nTotalSize = nSize * sizeof(SortColCtrl); SortColCtrl* pCtrls = (SortColCtrl*)malloc(nTotalSize); memset(pCtrls, 0, nTotalSize); for ( int ii=0; ii<nSize; ++ii ) { SortColCtrl* pCtrlCur = pCtrls + ii; pCtrlCur->dwCtrl = SORTCOLUMN_BY_LABEL_TYPE; pCtrlCur->nRow = vnLabelTypes[ii]; if(RCLT_PARAM == vnLabelTypes[ii]) { pCtrlCur->dwCtrl |= SORTCOLUMN_DESCENDING; //with time format pCtrlCur->dwCtrl |= SORTCOLUMN_AS_TIME; pCtrlCur->lpcszFormat = "0";//0 = hh:mm, or custom format "hh mm ss'.'##" } } wks.SortColumns(pCtrls, nSize); free(pCtrls); out_str("Sort error!"); }
Worksheet::Sort
origin.h