1 import { useMemo } from 'react';
3 import { useContactEmails } from '@proton/mail/contactEmails/hooks';
4 import type { ContactEmail } from '@proton/shared/lib/interfaces/contacts/Contact';
6 const compareContactEmailByName = (a: ContactEmail, b: ContactEmail) => {
7 return a.Name.localeCompare(b.Name);
10 const useContactEmailsSortedByName = () => {
11 const [contactEmails, loading] = useContactEmails();
12 return useMemo(() => {
13 return [[...(contactEmails || [])].sort(compareContactEmailByName), loading] as const;
17 export default useContactEmailsSortedByName;