function SortStr(Line : string) : string; var RetVar : string; begin case SortType of srtAlpha : Retvar := Line; srtInteger : Retvar := FormatFloat('000000000',StrToIntDef(trim(Line),0)); srtDouble : try Retvar := FormatFloat('000000000.000000',StrToFloat(trim(Line))); except RetVar := '0.00'; end; end;
Result := RetVar; end;
// Recursive QuickSort procedure QuickSort(Lo,Hi : integer; CC : TStrings);
procedure Sort(l,r: integer); var i,j : integer; x : string; begin i := l; j := r; x := SortStr(CC[(l+r) DIV 2]); repeat while SortStr(CC[i]) < x do inc(i); while x < SortStr(CC[j]) do dec(j); if i <= j then begin Temp.Assign(SG.Rows[j]); // Swap the 2 rows SG.Rows[j].Assign(SG.Rows[i]); SG.Rows[i].Assign(Temp); inc(i); dec(j); end; until i > j; if l < j then sort(l,j); if i < r then sort(i,r); end;
begin {quicksort}; Sort(Lo,Hi); end;
begin Temp := TStringList.Create; QuickSort(FromRow,ToRow,SG.Cols[ByColNumber]); Temp.Free; end;
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.