mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 11:25:29 -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
|
end
|
||||||
|
|
||||||
def sorted_titles(username, opt : SortOptions? = nil)
|
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
|
end
|
||||||
|
|
||||||
# Get all entries, including entries in nested titles
|
# 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
|
case opt.method
|
||||||
when .time_modified?
|
when .time_modified?
|
||||||
ary.sort! { |a, b| (a.mtime <=> b.mtime).or \
|
ary.sort { |a, b| (a.mtime <=> b.mtime).or \
|
||||||
compare_numerically a.title, b.title }
|
compare_numerically a.sort_title, b.sort_title }
|
||||||
when .progress?
|
when .progress?
|
||||||
ary.sort! do |a, b|
|
ary.sort do |a, b|
|
||||||
(a.load_percentage(username) <=> b.load_percentage(username)).or \
|
(a.load_percentage(username) <=> b.load_percentage(username)).or \
|
||||||
compare_numerically a.title, b.title
|
compare_numerically a.sort_title, b.sort_title
|
||||||
end
|
end
|
||||||
when .title?
|
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
|
else
|
||||||
unless opt.method.auto?
|
unless opt.method.auto?
|
||||||
Logger.warn "Unknown sorting method #{opt.not_nil!.method}. Using " \
|
Logger.warn "Unknown sorting method #{opt.not_nil!.method}. Using " \
|
||||||
"Auto instead"
|
"Auto instead"
|
||||||
end
|
end
|
||||||
ary.sort! { |a, b| compare_numerically a.title, b.title }
|
ary.sort { |a, b| compare_numerically a.sort_title, b.sort_title }
|
||||||
end
|
end
|
||||||
|
|
||||||
ary.reverse! unless opt.not_nil!.ascend
|
ary.reverse! unless opt.not_nil!.ascend
|
||||||
|
Loading…
x
Reference in New Issue
Block a user