mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 19:05:32 -04:00
Use sort_title, sort_titles in title page
This commit is contained in:
parent
8fea35fa51
commit
1ec8dcbfda
@ -253,7 +253,12 @@ class Title
|
||||
end
|
||||
|
||||
def sorted_titles(username, opt : SortOptions? = nil)
|
||||
titles
|
||||
if opt.nil?
|
||||
opt = SortOptions.from_info_json @dir, username
|
||||
end
|
||||
|
||||
# Helper function from src/util/util.cr
|
||||
sort_titles titles, opt.not_nil!, username
|
||||
end
|
||||
|
||||
# Get all entries, including entries in nested titles
|
||||
|
@ -91,21 +91,21 @@ def sort_titles(titles : Array(Title), opt : SortOptions, username : String)
|
||||
|
||||
case opt.method
|
||||
when .time_modified?
|
||||
ary.sort! { |a, b| (a.mtime <=> b.mtime).or \
|
||||
compare_numerically a.title, b.title }
|
||||
ary.sort { |a, b| (a.mtime <=> b.mtime).or \
|
||||
compare_numerically a.sort_title, b.sort_title }
|
||||
when .progress?
|
||||
ary.sort! do |a, b|
|
||||
ary.sort do |a, b|
|
||||
(a.load_percentage(username) <=> b.load_percentage(username)).or \
|
||||
compare_numerically a.title, b.title
|
||||
compare_numerically a.sort_title, b.sort_title
|
||||
end
|
||||
when .title?
|
||||
ary.sort! { |a, b| compare_numerically a.title, b.title }
|
||||
ary.sort { |a, b| compare_numerically a.sort_title, b.sort_title }
|
||||
else
|
||||
unless opt.method.auto?
|
||||
Logger.warn "Unknown sorting method #{opt.not_nil!.method}. Using " \
|
||||
"Auto instead"
|
||||
end
|
||||
ary.sort! { |a, b| compare_numerically a.title, b.title }
|
||||
ary.sort { |a, b| compare_numerically a.sort_title, b.sort_title }
|
||||
end
|
||||
|
||||
ary.reverse! unless opt.not_nil!.ascend
|
||||
|
Loading…
x
Reference in New Issue
Block a user