Sorting problem
-
Hi everybody. Can somebody direct me to a correct algorithm to solve the sort problem of the following array of data: ServerWeb.* ServerWebSomething1 ServerWebSomething2 ServerWeb3 ApplicationServer1 App.* ApplicationServer2 should be sorted as this: ApplicationServer1 ApplicationServer2 App.* ServerWebSomething1 ServerWebSomething2 ServerWeb3 ServerWeb.* The point is that the data is first sorted alphabetically, and then withing the similar types of data I need to get the data with more specific to the top and those less specific to the bottom. For instance, as ServerWeb.* covers all servers that starts with the "ServerWeb" it is the least distinctive, while ServerWebSomething1 is the most distinctive in that subgroup. This just puzzles me, I would appreciate any algorithm in any language if C# example is not available. Thanks.
-
Hi everybody. Can somebody direct me to a correct algorithm to solve the sort problem of the following array of data: ServerWeb.* ServerWebSomething1 ServerWebSomething2 ServerWeb3 ApplicationServer1 App.* ApplicationServer2 should be sorted as this: ApplicationServer1 ApplicationServer2 App.* ServerWebSomething1 ServerWebSomething2 ServerWeb3 ServerWeb.* The point is that the data is first sorted alphabetically, and then withing the similar types of data I need to get the data with more specific to the top and those less specific to the bottom. For instance, as ServerWeb.* covers all servers that starts with the "ServerWeb" it is the least distinctive, while ServerWebSomething1 is the most distinctive in that subgroup. This just puzzles me, I would appreciate any algorithm in any language if C# example is not available. Thanks.
What you need to do is to define a way to compare two of the values. If you just do that, you can then use any sorting algorithm. You can even make a class that implements ICompareable and use the SortedList class to sort them. What information does the names contain? How do you separate the different parts of information? Why is, for an example, "ServerWebSomething1" more distinctive than "ServerWeb3"? --- b { font-weight: normal; }