repo.or.cz
/
ProtonMail-WebClient.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Use source loader for email sprite icons
[ProtonMail-WebClient.git]
/
packages
/
utils
/
orderBy.ts
blob
83c82a3453761400e45171fbe0a2adcb094df178
1
/**
2
* Order collection of object by a specific key
3
*/
4
const orderBy = <T, K extends keyof T>(collection: T[], key: K) => {
5
return collection.slice().sort((a, b) => {
6
if (a[key] > b[key]) {
7
return 1;
8
}
9
if (a[key] < b[key]) {
10
return -1;
11
}
12
return 0;
13
});
14
};
15
16
export default orderBy;