1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Sort video captions

This commit is contained in:
Chocobozzz 2018-07-25 15:11:25 +02:00
parent f842e810b4
commit ad77475251
No known key found for this signature in database
GPG key ID: 583A612D890159BE
5 changed files with 37 additions and 15 deletions

View file

@ -101,7 +101,19 @@ function removeElementFromArray <T> (arr: T[], elem: T) {
if (index !== -1) arr.splice(index, 1)
}
function sortBy (obj: any[], key1: string, key2?: string) {
return obj.sort((a, b) => {
const elem1 = key2 ? a[key1][key2] : a[key1]
const elem2 = key2 ? b[key1][key2] : b[key1]
if (elem1 < elem2) return -1
if (elem1 === elem2) return 0
return 1
})
}
export {
sortBy,
objectToUrlEncoded,
getParameterByName,
populateAsyncUserVideoChannels,