001
27.05.2004, 12:13 Uhr
~freewilly
Gast
|
Hallo,
hatte dafür mal eine Quicksort Variante:
C++: |
void quicksort(TStringGrid *grid,int li,int re,int col,bool desc) { int nli=li,nre=re,mi=StrToInt(grid->Cells[col][(li+re)/2]); String temp; do { while (desc ? (mi < StrToInt(grid->Cells[col][nre])) : (mi>StrToInt(grid->Cells[col][nre]))) nre--; while (desc ? (StrToInt(grid->Cells[col][nli])<mi) : (StrToInt(grid->Cells[col][nli])>mi)) nli++; if (nli<=nre) { temp=grid->Rows[nli]->CommaText; grid->Rows[nli]->CommaText=grid->Rows[nre]->CommaText; grid->Rows[nre]->CommaText=temp; nli++; nre--; } } while (nli<nre); if (li<nre) quicksort(grid,li,nre,col,desc); if (nli<re) quicksort(grid,nli,re,col,desc); }
|
Aufruf mit:
C++: |
quicksort(StringGrid1,StringGrid1->FixedRows,StringGrid1->RowCount-1,Column,false);
|
|