Autor Beitrag
hassedelphi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101

WIN XP
D7 Enterprise
BeitragVerfasst: Sa 17.01.04 10:56 
hi

ich kann ein array super sortieren (wenn zahlen drin sind). aber wenn ich 'ne liste mit 20 wörtern nach alphabet ordnen soll hab ich keine planung. kann mir jmd. 'nen tipp geben?

ich hab schon versucht mit shortstrings zu arbeiten aber das hat nicht so recht gefunzt.

kann mir bitte jmd helfen (nur'n tipp).

_________________
you're not be able to help, that you're an human
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 17.01.04 11:05 
Strings kannst du genauso mit "<" und ">" vergleichen.
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Sa 17.01.04 11:10 
Sieh Dir mal TStringlist an, das könnte direkt sortieren..
hassedelphi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101

WIN XP
D7 Enterprise
BeitragVerfasst: Sa 17.01.04 11:58 
danke für den tipp, aber wenn ich mein array auf string umstelle kommt immer ein zugriffsverletzungsfehler.

wenn ich folgende zeile aus dem quelltext entferne passiert das nicht;

ausblenden Delphi-Quelltext
1:
2:
3:
4:
   while (j>=0and (a[j]>a[j+k]) do begin
     h:=a[j];a[j]:=a[j+k];a[j+k]:=h;
     if j>k then j:=j-k else j:=0;
   end;


das gehört zu einem shellsort verfahren. egal ob ich die zeilen (1 und 4) oder (2 und 3) wegnehme. der fehler kommt solange, bis alle 4 Zeilen nicht mehr gelesenn werden. a[x] sind immer strings von 3-4 Buchstaben. h ist hilfvariable (auch string). j,k sind integer. weiß jmd. warums nicht geht? (als a[x] und h integer waren hat's gefunzt)

_________________
you're not be able to help, that you're an human