From 2923c98d2b72332bf506bddac52001713657923c Mon Sep 17 00:00:00 2001
From: philippe L <philha@worteks.com>
Date: Tue, 23 Jan 2024 19:34:03 +0100
Subject: fix sorting for users in issue assignee selection and watcher

- dont call sort that is ruby sort and does not handle utf8 accentuated
  sorting
- use sorted when it is possible ( active record ).
- whenever sort is called on a collection remove it.
---
 app/helpers/application_helper.rb | 2 +-
 app/helpers/issues_helper.rb      | 2 +-
 app/models/issue.rb               | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a82163b76..6cd478956 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -647,7 +647,7 @@ module ApplicationHelper
       s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id)
     end
     groups = +''
-    collection.sort.each do |element|
+    collection.each do |element|
       if option_value_selected?(element, selected) || element.id.to_s == selected
         selected_attribute = ' selected="selected"'
       end
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 2453c1204..ca5c163e4 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -467,7 +467,7 @@ module IssuesHelper
     users = issue.watcher_users.select{|u| u.status == User::STATUS_ACTIVE}
     assignable_watchers = issue.project.principals.assignable_watchers.limit(21)
     if assignable_watchers.size <= 20
-      users += assignable_watchers.sort
+      users += assignable_watchers.sorted
     end
     users.uniq
   end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 17802d227..b2065e90c 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -993,7 +993,7 @@ class Issue < ActiveRecord::Base
     if assigned_to_id_was.present? && assignee = Principal.find_by_id(assigned_to_id_was)
       users << assignee
     end
-    users.uniq.sort
+    users.uniq
   end
 
   # Versions that the issue can be assigned to
-- 
2.34.1

