|
<< Click to Display Table of Contents >> Navigation: Telegram > 2024 > 06 > 11 > Telegram_2024-06-11T21 |
2024-06-11T21:49:35
hi
2024-06-11T21:49:46
hopes that you fine
2024-06-11T21:51:12
I am trying to sort number by delphi such as 1,2,15,1.5,13,30
2024-06-11T21:52:32
I need this such for drugs dose with my intraweb application
2024-06-11T21:52:35
thanks
2024-06-11T21:54:45
Add all to a stringlist, formatted, then sort and result is stringreplace #13#10 with comma
2024-06-11T21:55:46
thanks
2024-06-11T21:55:54
i will try
2024-06-11T21:56:52
quick and dirty... ( sl = TStringList )
sValues := '001.00,012.00,016.21';
sl.Text := stringreplace( sValues, ',', #13#10, [rfReplaceAll]);
sl.sort ;
sValues := StringReplace( sl.text, #13#10, ',', [ rfReplaceAll ]);
2024-06-11T21:57:53
but that's just a super quick idea. not fancy
2024-06-11T21:59:37
but the trick in that one is to replace your comma ( or separator ) with #13#10 (carriage return, line feed), then sort the stringlist, then replace the #13#10 with ',' comma again.... other methods are a lot more code. There are MANY ways to sort things, ranging from writing procedures and functions, to arrays etc. so the question is what kind of results are you looking for? In this example I'm just basically taking your \string\ of values and returning it sorted. It will sort correctly if all values have the same pattern, like \00000000.00\ so that's the trick.