<commit_before>(function () {
    angular
        .module('atlasSearchResults')
        .factory('geosearchFormatter', geosearchFormatterFactory);

    geosearchFormatterFactory.$inject = ['SEARCH_CONFIG'];

    function geosearchFormatterFactory (SEARCH_CONFIG) {
        return {
            format: format
        };

        function format (allSearchResults) {
            var allFeaturesFlattened = allSearchResults
                .map(function (searchResult) {
                    return searchResult.features.map(function (feature) {
                        return feature.properties;
                    });
                })
                .reduce(function (previous, current) {
                    return previous.concat(current);
                }, []);

            return SEARCH_CONFIG.COORDINATES_HIERARCHY
                .map(function (rawCategory) {
                    var formattedCategory = {
                        slug: rawCategory.slug || null,
                        label_singular: rawCategory.label_singular,
                        label_plural: rawCategory.label_plural,
                        results: allFeaturesFlattened
                            .filter(function (feature) {
                                return rawCategory.features.indexOf(feature.type) !== -1;
                            })
                            .map(function (feature) {
                                var subtype;

                                if (feature.opr_type) {
                                    subtype = feature.opr_type.toLowerCase();
                                } else if (feature.type.match(/^gebieden\//)) {
                                    subtype = feature.type.replace(/^gebieden\//, '');
                                } else {
                                    subtype = null;
                                }

                                return {
                                    label: feature.display,
                                    subtype: subtype,
                                    endpoint: feature.uri
                                };
                            }),
                        useIndenting: false
                    };

                    formattedCategory.count = formattedCategory.results.length;

                    return formattedCategory;
                })
                .filter(function (category) {
                    //Remove empty categories
                    return category.count > 0;
                });
        }
    }
})();<commit_msg>The geosearch features per API calls weren't sorted properly.<commit_after>(function () {
    angular
        .module('atlasSearchResults')
        .factory('geosearchFormatter', geosearchFormatterFactory);

    geosearchFormatterFactory.$inject = ['SEARCH_CONFIG'];

    function geosearchFormatterFactory (SEARCH_CONFIG) {
        return {
            format: format
        };

        function format (allSearchResults) {
            var allFeaturesFlattened = allSearchResults
                .map(function (searchResult) {
                    return searchResult.features.map(function (feature) {
                        return feature.properties;
                    });
                })
                .reduce(function (previous, current) {
                    return previous.concat(current);
                }, []);

            return SEARCH_CONFIG.COORDINATES_HIERARCHY
                .map(function (rawCategory) {
                    var formattedCategory = {
                        slug: rawCategory.slug || null,
                        label_singular: rawCategory.label_singular,
                        label_plural: rawCategory.label_plural,
                        results: allFeaturesFlattened
                            .filter(function (feature) {
                                return rawCategory.features.indexOf(feature.type) !== -1;
                            })
                            .sort(function (featureA, featureB) {
                                var indexA,
                                    indexB;

                                indexA = rawCategory.features.indexOf(featureA.type);
                                indexB = rawCategory.features.indexOf(featureB.type);

                                return indexA - indexB;
                            })
                            .map(function (feature) {
                                var subtype;

                                if (feature.opr_type) {
                                    subtype = feature.opr_type.toLowerCase();
                                } else if (feature.type.match(/^gebieden\//)) {
                                    subtype = feature.type.replace(/^gebieden\//, '');
                                } else {
                                    subtype = null;
                                }

                                return {
                                    label: feature.display,
                                    subtype: subtype,
                                    endpoint: feature.uri
                                };
                            }),
                        useIndenting: false
                    };

                    formattedCategory.count = formattedCategory.results.length;

                    return formattedCategory;
                })
                .filter(function (category) {
                    //Remove empty categories
                    return category.count > 0;
                });
        }
    }
})();
{'fraction_non_alphanumeric': 0.0772408837794144, 'fraction_numerical': 0.0007185198491108317, 'mean_word_length': 0.9213250517598344, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3438052', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1099, 'n_words': 197}