diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-25 15:11:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-25 15:11:25 +0200 |
commit | ad77475251c3516dd5851a08655be79d7bf76245 (patch) | |
tree | 3b816fa225a8b9f50bbdc6edd8bdc2d2dfbe5ce2 /client/src/app/shared/misc | |
parent | f842e810b450a34275d8d453d5d9431a4e1b882a (diff) | |
download | PeerTube-ad77475251c3516dd5851a08655be79d7bf76245.tar.gz PeerTube-ad77475251c3516dd5851a08655be79d7bf76245.tar.zst PeerTube-ad77475251c3516dd5851a08655be79d7bf76245.zip |
Sort video captions
Diffstat (limited to 'client/src/app/shared/misc')
-rw-r--r-- | client/src/app/shared/misc/utils.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts index 8381745f5..018271efe 100644 --- a/client/src/app/shared/misc/utils.ts +++ b/client/src/app/shared/misc/utils.ts | |||
@@ -101,7 +101,19 @@ function removeElementFromArray <T> (arr: T[], elem: T) { | |||
101 | if (index !== -1) arr.splice(index, 1) | 101 | if (index !== -1) arr.splice(index, 1) |
102 | } | 102 | } |
103 | 103 | ||
104 | function sortBy (obj: any[], key1: string, key2?: string) { | ||
105 | return obj.sort((a, b) => { | ||
106 | const elem1 = key2 ? a[key1][key2] : a[key1] | ||
107 | const elem2 = key2 ? b[key1][key2] : b[key1] | ||
108 | |||
109 | if (elem1 < elem2) return -1 | ||
110 | if (elem1 === elem2) return 0 | ||
111 | return 1 | ||
112 | }) | ||
113 | } | ||
114 | |||
104 | export { | 115 | export { |
116 | sortBy, | ||
105 | objectToUrlEncoded, | 117 | objectToUrlEncoded, |
106 | getParameterByName, | 118 | getParameterByName, |
107 | populateAsyncUserVideoChannels, | 119 | populateAsyncUserVideoChannels, |