<div dir="ltr">Hello,<div><br></div><div>First, thanks a lot for the rtl-generics units, this really was a great contribution to the Free Pascal community!<br><div><br></div><div>So, sometimes, I need to sort the values of a specialized key/value list, but I can't compile the adapted Delphi XE code below (I'm using MODE DELPHI):</div><div><br></div><div>=== begin code ===</div><div><br></div><div><div>var<br></div><div> key: string;</div><div> ordkeys: TArray<string>;</div><div> list: TDictionary<string, string>;</div><div>begin</div><div> list := TDictionary<string, string>.Create;</div><div> try</div><div> list.Add('a', 'aaa');</div><div> list.Add('b', 'bbb');</div><div> list.Add('c', 'ccc');</div><div> ordkeys := list.Keys.ToArray;</div><div> TArray.Sort<string>(ordkeys);</div><div> for key in ordkeys do</div><div> WriteLn(key, ' - ', list[key]);</div><div> finally</div><div> list.Free;</div><div> end;</div><div>end.</div></div><div><br></div><div>=== end code ===</div><div><br></div><div>I got:</div><div><br></div><div>'Error: Identifier not found "TArray"'</div><div><br></div><div>So I've fixed it with:</div><div><br></div><div>=== begin code ===<br></div><div><br></div><div>...</div><div><br></div><div><div>{$IFDEF FPC}</div><div> TArrayHelper<string>.Sort(ordkeys);</div><div>{$ELSE}</div><div> TArray.Sort<string>(ordkeys);</div><div>{$ENDIF}</div><div><br></div><div>...</div><div><br></div><div>=== end code ===<br></div><div><br></div><div>So, is this the best way to solve this problem?</div><div><br></div><div>Thank you!</div><div><br></div><div>P.S.: You should remove the {$H+} from the generics.* units, <a href="http://www.freepascal.org/docs-html/prog/progsu25.html" target="_blank">the mode Delphi already enables the long strings</a>.</div><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div>Silvio Clécio</div></div></div>
</div></div></div>