Project

General

Profile

Patch #29299 » replace-sort-with-sort_by-v2.diff

Go MAEDA, 2018-07-31 02:21

View differences:

app/controllers/settings_controller.rb (working copy)
46 46
    end
47 47

  
48 48
    @options = {}
49
    user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort{|a, b| a[1] <=> b[1]}
49
    user_format = User::USER_FORMATS.collect{|key, value| [key, value[:setting_order]]}.sort_by{|f| f[1]}
50 50
    @options[:user_format] = user_format.collect{|f| [User.current.name(f[0]), f[0].to_s]}
51 51
    @deliveries = ActionMailer::Base.perform_deliveries
52 52

  
app/helpers/activities_helper.rb (working copy)
21 21
  def sort_activity_events(events)
22 22
    events_by_group = events.group_by(&:event_group)
23 23
    sorted_events = []
24
    events.sort {|x, y| y.event_datetime <=> x.event_datetime}.each do |event|
24
    events.sort_by(&:event_datetime).reverse_each do |event|
25 25
      if group_events = events_by_group.delete(event.event_group)
26
        group_events.sort {|x, y| y.event_datetime <=> x.event_datetime}.each_with_index do |e, i|
26
        group_events.sort_by(&:event_datetime).reverse.each_with_index do |e, i|
27 27
          sorted_events << [e, i > 0]
28 28
        end
29 29
      end
app/helpers/issue_relations_helper.rb (working copy)
20 20
module IssueRelationsHelper
21 21
  def collection_for_relation_type_select
22 22
    values = IssueRelation::TYPES
23
    values.keys.sort{|x,y| values[x][:order] <=> values[y][:order]}.collect{|k| [l(values[k][:name]), k]}
23
    values.keys.sort_by{|k| values[k][:order]}.collect{|k| [l(values[k][:name]), k]}
24 24
  end
25 25
end
app/helpers/repositories_helper.rb (working copy)
269 269
        :href  => block_given? ? yield(commit.scmid) : commit.scmid
270 270
      }
271 271
    end
272
    heads.sort! { |head1, head2| head1.to_s <=> head2.to_s }
272
    heads.sort_by!(&:to_s)
273 273
    space = nil
274 274
    heads.each do |head|
275 275
      if commits_by_scmid.include? head.scmid
app/helpers/search_helper.rb (working copy)
55 55
  def render_results_by_type(results_by_type)
56 56
    links = []
57 57
    # Sorts types by results count
58
    results_by_type.keys.sort {|a, b| results_by_type[b] <=> results_by_type[a]}.each do |t|
58
    results_by_type.keys.sort_by {|k| results_by_type[k]}.reverse_each do |t|
59 59
      c = results_by_type[t]
60 60
      next if c == 0
61 61
      text = "#{type_label(t)} (#{c})"
app/models/query.rb (working copy)
118 118
  def value_object(object)
119 119
    if custom_field.visible_by?(object.project, User.current)
120 120
      cv = object.custom_values.select {|v| v.custom_field_id == @cf.id}
121
      cv.size > 1 ? cv.sort {|a,b| a.value.to_s <=> b.value.to_s} : cv.first
121
      cv.size > 1 ? cv.sort_by {|e| e.value.to_s} : cv.first
122 122
    else
123 123
      nil
124 124
    end
lib/redmine/helpers/gantt.rb (working copy)
619 619
      end
620 620

  
621 621
      def self.sort_issues!(issues)
622
        issues.sort! {|a, b| sort_issue_logic(a) <=> sort_issue_logic(b)}
622
        issues.sort_by! {|issue| sort_issue_logic(issue)}
623 623
      end
624 624

  
625 625
      def self.sort_issue_logic(issue)
lib/redmine/i18n.rb (working copy)
120 120
        valid_languages.
121 121
          select {|locale| ::I18n.exists?(:general_lang_name, locale)}.
122 122
          map {|lang| [ll(lang.to_s, :general_lang_name), lang.to_s]}.
123
          sort {|x,y| x.first <=> y.first }
123
          sort_by(&:first)
124 124
      else
125 125
        ActionController::Base.cache_store.fetch "i18n/languages_options/#{Redmine::VERSION}" do
126 126
          languages_options :cache => false
lib/redmine/scm/adapters/mercurial_adapter.rb (working copy)
206 206
               :path          => with_leading_slash(p),
207 207
               :from_path     => (cpmap.member?(p) ? with_leading_slash(cpmap[p]) : nil),
208 208
               :from_revision => (cpmap.member?(p) ? le['node'] : nil)}
209
            end.sort { |a, b| a[:path] <=> b[:path] }
209
            end.sort_by { |e| e[:path] }
210 210
            parents_ary = []
211 211
            as_ary(le['parents']['parent']).map do |par|
212 212
              parents_ary << par['__content__'] if par['__content__'] != "0000000000000000000000000000000000000000"
lib/redmine/scm/adapters/subversion_adapter.rb (working copy)
168 168
                            :from_revision => path['copyfrom-rev']
169 169
                            }
170 170
                end if logentry['paths'] && logentry['paths']['path']
171
                paths.sort! { |x,y| x[:path] <=> y[:path] }
171
                paths.sort_by! {|e| e[:path]}
172 172

  
173 173
                revisions << Revision.new({:identifier => logentry['revision'],
174 174
                              :author => (logentry['author'] ? logentry['author']['__content__'] : ""),
lib/tasks/permissions.rake (working copy)
2 2
  desc "List all permissions and the actions registered with them"
3 3
  task :permissions => :environment do
4 4
    puts "Permission Name - controller/action pairs"
5
    Redmine::AccessControl.permissions.sort {|a,b| a.name.to_s <=> b.name.to_s }.each do |permission|
5
    Redmine::AccessControl.permissions.sort_by {|p| p.name.to_s}.each do |permission|
6 6
      puts ":#{permission.name} - #{permission.actions.join(', ')}"
7 7
    end
8 8
  end
(2-2/2)