Hallo.
Ich möchte den Inhalt eines Stringgrids alphabetisch sortieren, bekomme den Code dafür aber nicht gebacken.
Kann mit jemand helfen?
P.S.: Folgender Code (abgeleitet von <a href="http://www.dsdt.info/tipps/?id=378" Target="_Blank">SelectionSort</a>) <u>funktioniert nicht</u>:
<b>procedure</b> TForm1.Sort(Down: Boolean);
<b>var</b> i, j, Pos: Integer;
<b>begin</b>
<b>for</b> i := 0 <b>to</b> StringGrid1.RowCount - 2 <b>do</b>
<b>begin</b>
Pos := i;
<b>for</b> j := i + 1 <b>to</b> StringGrid1.RowCount - 1 <b>do</b>
<b >if</b> Down <b>then</b>
&n bsp; <b>if </b>StringGrid1.Cells[j,0] > StringGrid1.Cells[Pos,0] <b>then</b>
&n bsp; Pos := j
<b >else</b>
&n bsp; <b>if </b>StringGrid1.Cells[j,0] < StringGrid1.Cells[Pos,0] <b>then</b>
&n bsp; Pos := j;
StringGrid1.Ro ws[j].Exchange(Pos,i)
<b>end;</b>
<b>end;</b>
Ich möchte den Inhalt eines Stringgrids alphabetisch sortieren, bekomme den Code dafür aber nicht gebacken.
Kann mit jemand helfen?
P.S.: Folgender Code (abgeleitet von <a href="http://www.dsdt.info/tipps/?id=378" Target="_Blank">SelectionSort</a>) <u>funktioniert nicht</u>:
<b>procedure</b> TForm1.Sort(Down: Boolean);
<b>var</b> i, j, Pos: Integer;
<b>begin</b>
<b>for</b> i := 0 <b>to</b> StringGrid1.RowCount - 2 <b>do</b>
<b>begin</b>
Pos := i;
<b>for</b> j := i + 1 <b>to</b> StringGrid1.RowCount - 1 <b>do</b>
<b >if</b> Down <b>then</b>
&n bsp; <b>if </b>StringGrid1.Cells[j,0] > StringGrid1.Cells[Pos,0] <b>then</b>
&n bsp; Pos := j
<b >else</b>
&n bsp; <b>if </b>StringGrid1.Cells[j,0] < StringGrid1.Cells[Pos,0] <b>then</b>
&n bsp; Pos := j;
StringGrid1.Ro ws[j].Exchange(Pos,i)
<b>end;</b>
<b>end;</b>
Comment