From 19629fe58671b29aaa1366897762eef0f41f28ed Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 8 Feb 2022 01:13:35 +0300 Subject: [PATCH] Update update-playlists.js --- scripts/commands/update-playlists.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/commands/update-playlists.js b/scripts/commands/update-playlists.js index 7b8cd1fd5a..0196b4a768 100644 --- a/scripts/commands/update-playlists.js +++ b/scripts/commands/update-playlists.js @@ -1,4 +1,5 @@ const _ = require('lodash') +const { orderBy } = require('natural-orderby') const { create: createPlaylist } = require('../core/playlist') const { db, logger, file } = require('../core') @@ -11,17 +12,10 @@ async function main() { for (const filepath in files) { let items = files[filepath] - items = items.sort(naturalOrder) + items = orderBy(items, ['channel_name'], ['asc']) const playlist = createPlaylist(items, { public: false }) await file.create(filepath, playlist.toString()) } } main() - -function naturalOrder(a, b) { - return a.channel_name.localeCompare(b.channel_name, undefined, { - numeric: true, - sensitivity: 'base' - }) -}