MCPcopy Create free account
hub / github.com/NatLabRockies/SAM / Sort

Method Sort

src/variablegrid.cpp:496–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494
495
496void VariableGridData::Sort(int col, bool ascending)
497{
498 // get all values for column
499 m_sorted = false;
500 wxArrayString col_values;
501 for (int row = 0; row < m_rows; row++)
502 col_values.Add(GetValue(row, col));
503 wxArrayString sorted_col_value(col_values);
504 // sort
505 sorted_col_value.Sort(!ascending);
506 // update index to get value
507 // TODO - handle same values
508
509 for (int row = 0; row < m_rows; row++)
510 m_sorted_index[row] = -1;
511 for (int row = 0; row < m_rows; row++)
512 {
513 int ndx = col_values.Index(sorted_col_value[row]);
514 if (m_sorted_index.Index(ndx) != wxNOT_FOUND)
515 col_values[ndx] = "|||||||||"; // hopefully not in original list
516 ndx = col_values.Index(sorted_col_value[row]);
517 m_sorted_index[row] = ndx;
518 }
519 m_sorted = true;
520}
521
522
523wxGridCellAttr *VariableGridData::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind)

Callers 10

ShowTableEditorFunction · 0.80
LoadFormListMethod · 0.80
LoadVarListMethod · 0.80
OnCommandMethod · 0.80
SetDataMethod · 0.80
Write_textMethod · 0.80
Write_JSONMethod · 0.80
WriteMethod · 0.80
OnShowMethod · 0.80
OnGridColSortMethod · 0.80

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected