Files
threshold-ui/ui/admin/app/utils/sort-name-with-id-fallback.js
T

12 lines
307 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
export function sortNameWithIdFallback(recordA, recordB) {
let a = recordA.attributes.name;
let b = recordB.attributes.name;
a = a ? a : recordA.id;
b = b ? b : recordB.id;
return String(a).localeCompare(String(b));
}