mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-05 12:25:32 -04:00
Use auto when an unknown sorting method is passed
This commit is contained in:
parent
94a1e63963
commit
687788767f
@ -509,13 +509,15 @@ class Title
|
|||||||
ary = @entries.zip(percentage_ary)
|
ary = @entries.zip(percentage_ary)
|
||||||
.sort { |a_tp, b_tp| a_tp[1] <=> b_tp[1] }
|
.sort { |a_tp, b_tp| a_tp[1] <=> b_tp[1] }
|
||||||
.map { |tp| tp[0] }
|
.map { |tp| tp[0] }
|
||||||
when .auto?
|
else
|
||||||
|
unless opt.method.auto?
|
||||||
|
Logger.warn "Unknown sorting method #{opt.not_nil!.method}. Using " \
|
||||||
|
"Auto instead"
|
||||||
|
end
|
||||||
sorter = ChapterSorter.new @entries.map { |e| e.title }
|
sorter = ChapterSorter.new @entries.map { |e| e.title }
|
||||||
ary = @entries.sort do |a, b|
|
ary = @entries.sort do |a, b|
|
||||||
sorter.compare a.title, b.title
|
sorter.compare a.title, b.title
|
||||||
end
|
end
|
||||||
else
|
|
||||||
raise "Unknown sorting method #{opt.not_nil!.method}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
ary.reverse! unless opt.not_nil!.ascend
|
ary.reverse! unless opt.not_nil!.ascend
|
||||||
@ -800,8 +802,6 @@ class Library
|
|||||||
ary = titles
|
ary = titles
|
||||||
|
|
||||||
case opt.not_nil!.method
|
case opt.not_nil!.method
|
||||||
when .auto?
|
|
||||||
ary.sort! { |a, b| compare_numerically a.title, b.title }
|
|
||||||
when .time_modified?
|
when .time_modified?
|
||||||
ary.sort! { |a, b| a.mtime <=> b.mtime }
|
ary.sort! { |a, b| a.mtime <=> b.mtime }
|
||||||
when .progress?
|
when .progress?
|
||||||
@ -809,7 +809,11 @@ class Library
|
|||||||
a.load_percentage(username) <=> b.load_percentage(username)
|
a.load_percentage(username) <=> b.load_percentage(username)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise "Unknown sorting method #{opt.not_nil!.method}"
|
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 }
|
||||||
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