@@ -230,33 +230,13 @@ export const autoCompare = (a, b) => {
230
230
return String ( a ) . localeCompare ( String ( b ) ) ;
231
231
} ;
232
232
233
- // Function to evaluate the complexity of a value
234
- // Higher values indicate more complex types that should be compared first
235
- export const getValueComplexity = ( value ) => {
236
- if ( value === null || value === undefined ) return 0 ;
237
- if ( typeof value === 'boolean' ) return 1 ;
238
- if ( typeof value === 'number' ) return 2 ;
239
- if ( typeof value === 'string' ) return 3 ;
240
- if ( Array . isArray ( value ) ) return 4 ;
241
- if ( typeof value === 'object' ) return 5 ;
242
- return 0 ;
243
- } ;
244
-
245
233
export const buildSortByKeys = ( keys ) => ( a , b ) => {
246
- // Sort keys based on value complexity and then find the first differing key
247
- const sortedKeys = keys . slice ( ) . sort ( ( keyA , keyB ) => {
248
- const complexityA = Math . max ( getValueComplexity ( a [ keyA ] ) , getValueComplexity ( b [ keyA ] ) ) ;
249
- const complexityB = Math . max ( getValueComplexity ( a [ keyB ] ) , getValueComplexity ( b [ keyB ] ) ) ;
250
-
251
- // Sort by complexity descending (more complex first), then by key name ascending
252
- if ( complexityA !== complexityB ) {
253
- return complexityB - complexityA ;
254
- }
255
- return keyA . localeCompare ( keyB ) ;
256
- } ) ;
234
+ // Filter out keys where either value is boolean, then use original strategy
235
+ const filteredKeys = keys . filter ( ( key ) =>
236
+ typeof a [ key ] !== 'boolean' && typeof b [ key ] !== 'boolean'
237
+ ) ;
257
238
258
- // Use deep comparison instead of reference comparison for objects
259
- const found = sortedKeys . find ( ( key ) => {
239
+ const found = filteredKeys . find ( ( key ) => {
260
240
const comparison = autoCompare ( a [ key ] , b [ key ] ) ;
261
241
return comparison !== 0 ;
262
242
} ) ;
0 commit comments