@@ -2,6 +2,7 @@ import type {TextStyle, ViewStyle} from 'react-native';
22import Onyx from 'react-native-onyx' ;
33import type { OnyxCollection } from 'react-native-onyx' ;
44import type { ValueOf } from 'type-fest' ;
5+ import type { LocaleContextProps } from '@components/LocaleContextProvider' ;
56import DotLottieAnimations from '@components/LottieAnimations' ;
67import type DotLottieAnimation from '@components/LottieAnimations/types' ;
78import type { MenuItemWithLink } from '@components/MenuItemList' ;
@@ -51,7 +52,6 @@ import {convertToDisplayString} from './CurrencyUtils';
5152import DateUtils from './DateUtils' ;
5253import { isDevelopment } from './Environment/Environment' ;
5354import interceptAnonymousUser from './interceptAnonymousUser' ;
54- import localeCompare from './LocaleCompare' ;
5555import { formatPhoneNumber } from './LocalePhoneNumber' ;
5656import { translateLocal } from './Localize' ;
5757import Navigation from './Navigation/Navigation' ;
@@ -1291,38 +1291,39 @@ function getSortedSections(
12911291 type : SearchDataTypes ,
12921292 status : SearchStatus ,
12931293 data : ListItemDataType < typeof type , typeof status > ,
1294+ localeCompare : LocaleContextProps [ 'localeCompare' ] ,
12941295 sortBy ?: SearchColumnType ,
12951296 sortOrder ?: SortOrder ,
12961297 groupBy ?: SearchGroupBy ,
12971298) {
12981299 if ( type === CONST . SEARCH . DATA_TYPES . CHAT ) {
1299- return getSortedReportActionData ( data as ReportActionListItemType [ ] ) ;
1300+ return getSortedReportActionData ( data as ReportActionListItemType [ ] , localeCompare ) ;
13001301 }
13011302 if ( type === CONST . SEARCH . DATA_TYPES . TASK ) {
1302- return getSortedTaskData ( data as TaskListItemType [ ] , sortBy , sortOrder ) ;
1303+ return getSortedTaskData ( data as TaskListItemType [ ] , localeCompare , sortBy , sortOrder ) ;
13031304 }
13041305
13051306 if ( groupBy ) {
13061307 // Disabling the default-case lint rule here is actually safer as this forces us to make the switch cases exhaustive
13071308 // eslint-disable-next-line default-case
13081309 switch ( groupBy ) {
13091310 case CONST . SEARCH . GROUP_BY . REPORTS :
1310- return getSortedReportData ( data as TransactionReportGroupListItemType [ ] ) ;
1311+ return getSortedReportData ( data as TransactionReportGroupListItemType [ ] , localeCompare ) ;
13111312 case CONST . SEARCH . GROUP_BY . MEMBERS :
13121313 return getSortedMemberData ( data as TransactionMemberGroupListItemType [ ] ) ;
13131314 case CONST . SEARCH . GROUP_BY . CARDS :
13141315 return getSortedCardData ( data as TransactionCardGroupListItemType [ ] ) ;
13151316 }
13161317 }
13171318
1318- return getSortedTransactionData ( data as TransactionListItemType [ ] , sortBy , sortOrder ) ;
1319+ return getSortedTransactionData ( data as TransactionListItemType [ ] , localeCompare , sortBy , sortOrder ) ;
13191320}
13201321
13211322/**
13221323 * Compares two values based on a specified sorting order and column.
13231324 * Handles both string and numeric comparisons, with special handling for absolute values when sorting by total amount.
13241325 */
1325- function compareValues ( a : unknown , b : unknown , sortOrder : SortOrder , sortBy : string ) : number {
1326+ function compareValues ( a : unknown , b : unknown , sortOrder : SortOrder , sortBy : string , localeCompare : LocaleContextProps [ 'localeCompare' ] ) : number {
13261327 const isAsc = sortOrder === CONST . SEARCH . SORT_ORDER . ASC ;
13271328
13281329 if ( a === undefined || b === undefined ) {
@@ -1346,7 +1347,7 @@ function compareValues(a: unknown, b: unknown, sortOrder: SortOrder, sortBy: str
13461347 * @private
13471348 * Sorts transaction sections based on a specified column and sort order.
13481349 */
1349- function getSortedTransactionData ( data : TransactionListItemType [ ] , sortBy ?: SearchColumnType , sortOrder ?: SortOrder ) {
1350+ function getSortedTransactionData ( data : TransactionListItemType [ ] , localeCompare : LocaleContextProps [ 'localeCompare' ] , sortBy ?: SearchColumnType , sortOrder ?: SortOrder ) {
13501351 if ( ! sortBy || ! sortOrder ) {
13511352 return data ;
13521353 }
@@ -1361,11 +1362,11 @@ function getSortedTransactionData(data: TransactionListItemType[], sortBy?: Sear
13611362 const aValue = sortingProperty === 'comment' ? a . comment ?. comment : a [ sortingProperty as keyof TransactionListItemType ] ;
13621363 const bValue = sortingProperty === 'comment' ? b . comment ?. comment : b [ sortingProperty as keyof TransactionListItemType ] ;
13631364
1364- return compareValues ( aValue , bValue , sortOrder , sortingProperty ) ;
1365+ return compareValues ( aValue , bValue , sortOrder , sortingProperty , localeCompare ) ;
13651366 } ) ;
13661367}
13671368
1368- function getSortedTaskData ( data : TaskListItemType [ ] , sortBy ?: SearchColumnType , sortOrder ?: SortOrder ) {
1369+ function getSortedTaskData ( data : TaskListItemType [ ] , localeCompare : LocaleContextProps [ 'localeCompare' ] , sortBy ?: SearchColumnType , sortOrder ?: SortOrder ) {
13691370 if ( ! sortBy || ! sortOrder ) {
13701371 return data ;
13711372 }
@@ -1380,17 +1381,17 @@ function getSortedTaskData(data: TaskListItemType[], sortBy?: SearchColumnType,
13801381 const aValue = a [ sortingProperty as keyof TaskListItemType ] ;
13811382 const bValue = b [ sortingProperty as keyof TaskListItemType ] ;
13821383
1383- return compareValues ( aValue , bValue , sortOrder , sortingProperty ) ;
1384+ return compareValues ( aValue , bValue , sortOrder , sortingProperty , localeCompare ) ;
13841385 } ) ;
13851386}
13861387
13871388/**
13881389 * @private
13891390 * Sorts report sections based on a specified column and sort order.
13901391 */
1391- function getSortedReportData ( data : TransactionReportGroupListItemType [ ] ) {
1392+ function getSortedReportData ( data : TransactionReportGroupListItemType [ ] , localeCompare : LocaleContextProps [ 'localeCompare' ] ) {
13921393 for ( const report of data ) {
1393- report . transactions = getSortedTransactionData ( report . transactions , CONST . SEARCH . TABLE_COLUMNS . DATE , CONST . SEARCH . SORT_ORDER . DESC ) ;
1394+ report . transactions = getSortedTransactionData ( report . transactions , localeCompare , CONST . SEARCH . TABLE_COLUMNS . DATE , CONST . SEARCH . SORT_ORDER . DESC ) ;
13941395 }
13951396 return data . sort ( ( a , b ) => {
13961397 const aNewestTransaction = a . transactions ?. at ( 0 ) ?. modifiedCreated ? a . transactions ?. at ( 0 ) ?. modifiedCreated : a . transactions ?. at ( 0 ) ?. created ;
@@ -1424,7 +1425,7 @@ function getSortedCardData(data: TransactionCardGroupListItemType[]) {
14241425 * @private
14251426 * Sorts report actions sections based on a specified column and sort order.
14261427 */
1427- function getSortedReportActionData ( data : ReportActionListItemType [ ] ) {
1428+ function getSortedReportActionData ( data : ReportActionListItemType [ ] , localeCompare : LocaleContextProps [ 'localeCompare' ] ) {
14281429 return data . sort ( ( a , b ) => {
14291430 const aValue = a ?. created ;
14301431 const bValue = b ?. created ;
0 commit comments