|
25 | 25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
26 | 26 | ****************************************************************************/ |
27 | 27 |
|
| 28 | +#include <algorithm> |
| 29 | +#include <string> |
| 30 | +#include <vector> |
| 31 | + |
28 | 32 | #include "mapserver.h" |
29 | 33 | #include "mapogcapi.h" |
30 | 34 | #include "mapserv-index.h" |
@@ -495,16 +499,25 @@ int msOGCAPIDispatchIndexRequest(mapservObj *mapserv, configObj *config) { |
495 | 499 | return MS_FAILURE; |
496 | 500 | } |
497 | 501 |
|
| 502 | + // Collect keys and sort alphabetically (case-insensitive) |
| 503 | + std::vector<std::string> keys; |
498 | 504 | const char *key = NULL; |
499 | | - json links = json::array(); |
500 | | - |
501 | 505 | while ((key = msNextKeyFromHashTable(&config->maps, key)) != NULL) { |
502 | | - if (mapObj *map = getMapFromConfig(config, key)) { |
503 | | - links.push_back(createMapSummary(map, key, request)); |
| 506 | + keys.push_back(key); |
| 507 | + } |
| 508 | + std::sort(keys.begin(), keys.end(), |
| 509 | + [](const std::string &a, const std::string &b) { |
| 510 | + return strcasecmp(a.c_str(), b.c_str()) < 0; |
| 511 | + }); |
| 512 | + |
| 513 | + json links = json::array(); |
| 514 | + for (const auto &k : keys) { |
| 515 | + if (mapObj *map = getMapFromConfig(config, k.c_str())) { |
| 516 | + links.push_back(createMapSummary(map, k.c_str(), request)); |
504 | 517 | msFreeMap(map); |
505 | 518 | } else { |
506 | 519 | // there was a problem loading the map |
507 | | - links.push_back(createMapError(key)); |
| 520 | + links.push_back(createMapError(k.c_str())); |
508 | 521 | } |
509 | 522 | } |
510 | 523 |
|
|
0 commit comments