From 5c8826a2a1fe2fe973ee0068a2337404d1cd3a31 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Sat, 11 Jul 2026 16:45:16 +0300 Subject: [PATCH] cloudstorage: add natural sort (#15662) --- plugins/cloudstorage.koplugin/cloudstorage.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/cloudstorage.koplugin/cloudstorage.lua b/plugins/cloudstorage.koplugin/cloudstorage.lua index 9cffe4477..36a2a5489 100644 --- a/plugins/cloudstorage.koplugin/cloudstorage.lua +++ b/plugins/cloudstorage.koplugin/cloudstorage.lua @@ -15,6 +15,7 @@ local UIManager = require("ui/uimanager") local ffiUtil = require("ffi/util") local filemanagerutil = require("apps/filemanager/filemanagerutil") local lfs = require("libs/libkoreader-lfs") +local sort = require("sort") local util = require("util") local _ = require("gettext") local N_ = _.ngettext @@ -28,6 +29,13 @@ local CloudStorage = BookList:extend{ return ffiUtil.strcoll(a.text, b.text) end, }, + natural = { + text = _("name (natural sorting)"), + sort_func = function(a, b) + local natsort = sort.natsort_cmp() + return natsort(a.text, b.text) + end, + }, type = { text = _("type"), sort_func = function(a, b) @@ -633,9 +641,11 @@ function CloudStorage:showPlusCloudDialog() text = T(_("Sort by: %1"), self.collates[self.collate].text), callback = function() UIManager:show(ButtonSelector:new{ + width_factor = 0.5, current_value = self.collate, values = { { self.collates["strcoll"].text, "strcoll" }, + { self.collates["natural"].text, "natural" }, { self.collates["type"].text, "type" }, { self.collates["size"].text, "size" }, { self.collates["date"].text, "date" },