REFACTOR: Remove `_.sortBy`

REFACTOR: Remove _.sortBy

diff --git a/app/assets/javascripts/admin/components/themes-list.js b/app/assets/javascripts/admin/components/themes-list.js
index 153e9ae..d9434e5 100644
--- a/app/assets/javascripts/admin/components/themes-list.js
+++ b/app/assets/javascripts/admin/components/themes-list.js
@@ -52,16 +52,19 @@ export default Component.extend({
     if (this.componentsTabActive) {
       return themes.filter(theme => theme.get("parent_themes.length") > 0);
     } else {
-      themes = themes.filter(
-        theme => theme.get("user_selectable") || theme.get("default")
-      );
-      return _.sortBy(themes, t => {
-        return [
-          !t.get("default"),
-          !t.get("user_selectable"),
-          t.get("name").toLowerCase()
-        ];
-      });
+      return themes
+        .filter(theme => theme.get("user_selectable") || theme.get("default"))
+        .sort((a, b) => {
+          if (a.get("default") && !b.get("default")) {
+            return -1;
+          } else if (b.get("default")) {
+            return 1;
+          }
+          return a
+            .get("name")
+            .toLowerCase()
+            .localeCompare(b.get("name").toLowerCase());
+        });
     }
   },
 
diff --git a/app/assets/javascripts/discourse/app/controllers/badges/index.js b/app/assets/javascripts/discourse/app/controllers/badges/index.js
index e056401..15b699e 100644
--- a/app/assets/javascripts/discourse/app/controllers/badges/index.js
+++ b/app/assets/javascripts/discourse/app/controllers/badges/index.js
@@ -1,20 +1,20 @@
 import discourseComputed from "discourse-common/utils/decorators";
 import Controller from "@ember/controller";
 
+function badgeKey(badge) {
+  let pos = badge.get("badge_grouping.position");
+  let type = badge.get("badge_type_id");
+  let name = badge.get("name");
+  return ("000" + pos).slice(-4) + (10 - type) + name;
+}
+
 export default Controller.extend({
   @discourseComputed("model")
   badgeGroups(model) {
-    var sorted = _.sortBy(model, function(badge) {
-      var pos = badge.get("badge_grouping.position");
-      var type = badge.get("badge_type_id");
-      var name = badge.get("name");
-
-      return ("000" + pos).slice(-4) + (10 - type) + name;
-    });
-
-    var grouped = [];
-    var group = [],
-      groupId;
+    let sorted = model.sort((a, b) => badgeKey(a).localeCompare(badgeKey(b)));
+    let grouped = [];
+    let group = [];
+    let groupId;
 
     sorted.forEach(function(badge) {
       if (groupId !== badge.badge_grouping_id) {
diff --git a/app/assets/javascripts/discourse/app/mixins/user-fields-validation.js b/app/assets/javascripts/discourse/app/mixins/user-fields-validation.js
index 46051a9..09c11e2 100644
--- a/app/assets/javascripts/discourse/app/mixins/user-fields-validation.js
+++ b/app/assets/javascripts/discourse/app/mixins/user-fields-validation.js
@@ -13,9 +13,9 @@ export default Mixin.create({
 
     let userFields = this.site.get("user_fields");
     if (userFields) {
-      userFields = _.sortBy(userFields, "position").map(function(f) {
-        return EmberObject.create({ value: null, field: f });
-      });
+      userFields = userFields
+        .sortBy("position")
+        .map(f => EmberObject.create({ value: null, field: f }));
     }
     this.set("userFields", userFields);
   },
diff --git a/app/assets/javascripts/discourse/app/models/category.js b/app/assets/javascripts/discourse/app/models/category.js
index 049a1bb..6355188 100644
--- a/app/assets/javascripts/discourse/app/models/category.js
+++ b/app/assets/javascripts/discourse/app/models/category.js
@@ -544,9 +544,7 @@ Category.reopenClass({
       }
     }
 
-    return _.sortBy(data, category => {
-      return category.get("read_restricted");
-    });
+    return data.sortBy("read_restricted");
   }
 });
 

GitHub sha: 17bca14c

This commit appears in #10566 which was merged by eviltrout.