@@ -10,7 +10,7 @@ import {getLastActorDisplayName} from '@libs/OptionsListUtils';
1010import type * as PolicyUtils from '@libs/PolicyUtils' ;
1111import { getOriginalMessage , getReportActionMessageText } from '@libs/ReportActionsUtils' ;
1212import { formatReportLastMessageText , generateReportID , getAllReportErrors , getReasonAndReportActionThatRequiresAttention , getReportPreviewMessage } from '@libs/ReportUtils' ;
13- import SidebarUtils , { _categorizeReportsForLHN , _combineReportCategories , _sortCategorizedReports } from '@libs/SidebarUtils' ;
13+ import SidebarUtils , { _buildSortKey , _categorizeReportsForLHN , _combineReportCategories , _sortCategorizedReports } from '@libs/SidebarUtils' ;
1414import initOnyxDerivedValues from '@userActions/OnyxDerived' ;
1515import CONST from '@src/CONST' ;
1616import IntlStore from '@src/languages/IntlStore' ;
@@ -3367,6 +3367,30 @@ describe('SidebarUtils', () => {
33673367 } ) ;
33683368 } ) ;
33693369
3370+ describe ( 'buildSortKey' , ( ) => {
3371+ it ( 'should sort accented characters by Unicode code point, not locale-aware order' , ( ) => {
3372+ // Given names with accented characters
3373+ const cafeAccented = _buildSortKey ( 'Café' ) ;
3374+ const cafePlain = _buildSortKey ( 'Cafe' ) ;
3375+
3376+ // Then accented "é" sorts after plain "e" by code point
3377+ expect ( cafeAccented > cafePlain ) . toBe ( true ) ;
3378+ } ) ;
3379+
3380+ it ( 'should be case-insensitive' , ( ) => {
3381+ expect ( _buildSortKey ( 'Alpha' ) ) . toBe ( _buildSortKey ( 'alpha' ) ) ;
3382+ expect ( _buildSortKey ( 'ZEBRA' ) ) . toBe ( _buildSortKey ( 'zebra' ) ) ;
3383+ } ) ;
3384+
3385+ it ( 'should zero-pad numeric segments for natural sort order' , ( ) => {
3386+ const report2 = _buildSortKey ( 'Report 2' ) ;
3387+ const report10 = _buildSortKey ( 'Report 10' ) ;
3388+
3389+ // Then "Report 2" sorts before "Report 10"
3390+ expect ( report2 < report10 ) . toBe ( true ) ;
3391+ } ) ;
3392+ } ) ;
3393+
33703394 describe ( 'combineReportCategories' , ( ) => {
33713395 it ( 'should combine categories in correct order' , ( ) => {
33723396 // Given the reports are created
0 commit comments