From 3220e909c83a6d266849bae05163cec793f10387 Mon Sep 17 00:00:00 2001
From: Ryan Laurie <30528226+iethree@users.noreply.github.com>
Date: Thu, 16 Feb 2023 18:58:36 -0700
Subject: [PATCH] sort models alphabetically in action picker (#28376)

---
 .../actions/containers/ActionPicker/ActionPicker.tsx | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/frontend/src/metabase/actions/containers/ActionPicker/ActionPicker.tsx b/frontend/src/metabase/actions/containers/ActionPicker/ActionPicker.tsx
index 4d24cebf262..71788343584 100644
--- a/frontend/src/metabase/actions/containers/ActionPicker/ActionPicker.tsx
+++ b/frontend/src/metabase/actions/containers/ActionPicker/ActionPicker.tsx
@@ -1,4 +1,4 @@
-import React, { useState } from "react";
+import React, { useState, useMemo } from "react";
 import { t } from "ttag";
 
 import { useToggle } from "metabase/hooks/use-toggle";
@@ -31,9 +31,15 @@ export default function ActionPicker({
   onClick: (action: WritebackAction) => void;
   currentAction?: WritebackAction;
 }) {
+  const sortedModels =
+    useMemo(
+      () => models?.sort((a, b) => a.name.localeCompare(b.name)),
+      [models],
+    ) ?? [];
+
   return (
     <div className="scroll-y">
-      {models.map(model => (
+      {sortedModels.map(model => (
         <ConnectedModelActionPicker
           key={model.id}
           model={model}
@@ -41,7 +47,7 @@ export default function ActionPicker({
           currentAction={currentAction}
         />
       ))}
-      {!models.length && (
+      {!sortedModels.length && (
         <EmptyState
           message={t`No models found`}
           action={t`Create new model`}
-- 
GitLab