JSFiddle - React, Tailwind, and code Playground

by Graham Fairweather

JavaScript

var x = [
    {
        "destination_country_id":null,
        "primary_cost":"9.50",
        "region_id":null,
        "destination_country_name":"Everywhere Else",
    },
    {
        "destination_country_id":105,
        "primary_cost":"8.00",
        "region_id":null,
        "destination_country_name":"United Kingdom",
    },
    {
        "destination_country_id":209,
        "primary_cost":"9.50",
        "region_id":null,
        "destination_country_name":"United States",
    },
    {
        "destination_country_id":123,
        "primary_cost":"5.00",
        "region_id":null,
        "destination_country_name":"Ireland",
    },
    {
        "destination_country_id":185,
        "primary_cost":"5.00",
        "region_id":null,
        "destination_country_name":"France",
    },
    {
        "destination_country_id":145,
        "primary_cost":"5.00",
        "region_id":null,
        "destination_country_name":"Spain",
    }
];

// where x is your array of objects
x.sort(function (a, b) {
    // sorts everything alphabetically
    return a.destination_country_name.localeCompare(b.destination_country_name);
}).sort(function (a, b) {
    // moves only this to country to top
    return +(!b.destination_country_name.localeCompare('United States'));
}).sort(function (a, b) {
    // moves only this to country to top
    return +(!b.destination_country_name.localeCompare('United Kingdom'));
}).sort(function (a, b) {
    // moves only this to country to top
    return +(!b.destination_country_name.localeCompare('Ireland'));
}).sort(function (a, b) {
    // moves only this to country to bottom
    return +(!a.destination_country_name.localeCompare('Everywhere Else'));
});

console.log(JSON.stringify(x, ['destination_country_name']));