In the project that I am working on, it would be nice if I could sort the list of lists in memory and compare with the SQL server table ordered by these addresses. Unfortunately, when the ordered list is returned by SQL Server, the order is not immediately apparent.
What would be the best way to sort this in a memory list so that the order is the same as SQL Server?
For example, the query " SELECT ID FROM TABLE1 ORDER BY ID " returns:
A46030EC-BF3A-4F7C-88CC-00117DBC1A52 159A0A9D-18B7-4D6C-ABB3-005FAB666D91 3C58CFC5-1829-481C-9686-007CE71132B8 15A96D5F-DAFB-4EF1-9202-00B201CE5151 BCFDE733-0AB0-483F-B912-00BF93F6FA7E 6CC06558-7670-4879-9D3F-00CB3D3649BD
For this question, suppose I have an array of strings that contain the guid values above, however in the following order:
159A0A9D-18B7-4D6C-ABB3-005FAB666D91 15A96D5F-DAFB-4EF1-9202-00B201CE5151 6CC06558-7670-4879-9D3F-00CB3D3649BD 8A9325AF-A84E-4BDB-AFA8-C9D09D7FC064 A46030EC-BF3A-4F7C-88CC-00117DBC1A52 BCFDE733-0AB0-483F-B912-00BF93F6FA7E
I want to see that I am missing one of the SQL query, and there is one that the SQL query did not have. The fastest way, obviously, is to have both lists sorted the same way, but I don’t want to execute a query like “ SELECT ID FROM TABLE1 ORDER BY cast(ID as varchar(100)) ” but rather I’ll fix the sorting on the Delphi side.
source share