Fix sorting. Closes #16
This commit is contained in:
@@ -77,15 +77,14 @@ export class TranslationCollection {
|
|||||||
|
|
||||||
public sort(compareFn?: (a: string, b: string) => number): TranslationCollection {
|
public sort(compareFn?: (a: string, b: string) => number): TranslationCollection {
|
||||||
if (!compareFn) {
|
if (!compareFn) {
|
||||||
// if no compare functions is provided use a case insensitive sorting function
|
// If no compare function is provided use a case insensitive sorting function
|
||||||
compareFn = (a, b) => a.toLowerCase().localeCompare(b.toLowerCase());
|
compareFn = (a: string, b: string) => a.toLowerCase().localeCompare(b.toLowerCase());
|
||||||
}
|
}
|
||||||
|
let values: TranslationType = {};
|
||||||
let collection = new TranslationCollection();
|
this.keys().sort(compareFn).forEach((key) => {
|
||||||
let sortedKeys = this.keys().sort(compareFn);
|
values[key] = this.get(key);
|
||||||
sortedKeys.forEach((key) => {
|
|
||||||
collection = collection.add(key, this.get(key));
|
|
||||||
});
|
});
|
||||||
return collection;
|
|
||||||
|
return new TranslationCollection(values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user