-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsort-tab.js
More file actions
29 lines (23 loc) · 1.56 KB
/
sort-tab.js
File metadata and controls
29 lines (23 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const tab = `
| admins | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)> | Ids of bot admins | None | ✓ |
| mode | development or production | The mode for run application | development | ✓ |
| joinThreadsOnCreate | [Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) | If bot should join threads on create | false | ✓ |
| managers | [ClientManagersOptions](#clientmanagersoptions) | The options for the managers | | ✓ |
`;
// const arr = tap.split("\n");
// arr.forEach((line) => {
// const key = line.split("|")[1].trim();
// });
// Sorth the tab by the first column
const sortTab = (tab) => {
const arr = tab.split("\n");
const sorted = arr
.filter((i) => i && i !== "\n")
.sort((a, b) => {
const aKey = a.split("|")[1].trim();
const bKey = b.split("|")[1].trim();
return aKey.localeCompare(bKey);
});
return sorted.join("\n");
};
console.log(sortTab(tab));