@@ -121,6 +121,20 @@ function defineLazyGetters(object, getterDefObj, stats) {
121121 return object
122122}
123123
124+ let _localeCompare
125+ /*@__NO_SIDE_EFFECTS__ */
126+ function entryKeyComparator ( a , b ) {
127+ if ( _localeCompare === undefined ) {
128+ const sorts = /*@__PURE__ */ require ( './sorts' )
129+ _localeCompare = sorts . localeCompare
130+ }
131+ const keyA = a [ 0 ]
132+ const keyB = b [ 0 ]
133+ const strKeyA = typeof keyA === 'string' ? keyA : String ( keyA )
134+ const strKeyB = typeof keyB === 'string' ? keyB : String ( keyB )
135+ return _localeCompare ( strKeyA , strKeyB )
136+ }
137+
124138/*@__NO_SIDE_EFFECTS__ */
125139function getOwnPropertyValues ( obj ) {
126140 if ( obj === null || obj === undefined ) {
@@ -251,25 +265,23 @@ function toSortedObject(obj) {
251265
252266/*@__NO_SIDE_EFFECTS__ */
253267function toSortedObjectFromEntries ( entries ) {
254- const { length } = entries
255- if ( ! length ) {
256- return { }
257- }
258- const stringEntries = [ ]
268+ const otherEntries = [ ]
259269 const symbolEntries = [ ]
260- for ( let i = 0 ; i < length ; i += 1 ) {
261- const entry = entries [ i ]
270+ // Use for-of to work with entries iterators.
271+ for ( const entry of entries ) {
262272 if ( typeof entry [ 0 ] === 'symbol' ) {
263273 symbolEntries . push ( entry )
264274 } else {
265- stringEntries . push ( entry )
275+ otherEntries . push ( entry )
266276 }
267277 }
268- const { localeCompare } = /*@__PURE__ */ require ( './sorts' )
278+ if ( ! otherEntries . length && ! symbolEntries . length ) {
279+ return [ ]
280+ }
269281 return ObjectFromEntries ( [
270282 // The String constructor is safe to use with symbols.
271- ...symbolEntries . sort ( ( a , b ) => localeCompare ( String ( a [ 0 ] ) , String ( b [ 0 ] ) ) ) ,
272- ...stringEntries . sort ( ( a , b ) => localeCompare ( a [ 0 ] , b [ 0 ] ) )
283+ ...symbolEntries . sort ( entryKeyComparator ) ,
284+ ...otherEntries . sort ( entryKeyComparator )
273285 ] )
274286}
275287
0 commit comments