signal-desktop/ts/util/sortByTitle.ts

13 lines
277 B
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
type HasTitle = {
title: string;
};
export function sortByTitle<T extends HasTitle>(
arr: ReadonlyArray<T>
): Array<T> {
return [...arr].sort((a, b) => a.title.localeCompare(b.title));
}