// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

#include "SearchResultSectionOrder.h"

#include "SearchResultModel.h"
#include "SearchVendorNames.h"

namespace ExampleApp
{
    namespace SearchResultSection
    {
        namespace View
        {
            bool SearchResultSectionOrder::operator() (const Search::SdkModel::SearchResultModel& a, const Search::SdkModel::SearchResultModel& b)
            {
                //GeoNames results on top
                if(a.GetVendor() != b.GetVendor() && a.GetVendor() == Search::GeoNamesVendorName)
                {
                        return true;
                }
                //Order GeoNames results as they came in
                if(a.GetVendor() == Search::GeoNamesVendorName || b.GetVendor() == Search::GeoNamesVendorName)
                {
                    return false;
                }
                return a < b;
            }
        }
    }
}
// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

#include <limits>
#include <map>

#include "SearchResultSectionOrder.h"

#include "SearchResultModel.h"
#include "SearchVendorNames.h"

namespace ExampleApp
{
    namespace SearchResultSection
    {
        namespace View
        {
            namespace
            {
                int VendorPriority(const std::string& vendor)
                {
                    const int HighestPriority = std::numeric_limits<int>::max();
                    enum AscendingVendorPriority {
                        EegeoVendorPriority,
                        YelpVendorPriority,
                        GeoNamesVendorPriority
                    };

                    static const std::map<std::string, int> vendorPriorities{
                        {Search::EegeoVendorName,    EegeoVendorPriority},
                        {Search::YelpVendorName,     YelpVendorPriority},
                        {Search::GeoNamesVendorName, GeoNamesVendorPriority}};

                    const std::map<std::string, int>::const_iterator vendorIx = vendorPriorities.find(vendor);
                    return vendorIx != vendorPriorities.end()
                        ? vendorIx->second
                        : HighestPriority;
                }
            }

            bool SearchResultSectionOrder::operator() (const Search::SdkModel::SearchResultModel& a, const Search::SdkModel::SearchResultModel& b)
            {
                return VendorPriority(a.GetVendor()) < VendorPriority(b.GetVendor());
            }
        }
    }
}
Order search result display order by vendor to more closely match web results. Buddy: Blair.
Order search result display order by vendor to more closely match web results.
Buddy: Blair.
