Skip to content

Commit

Permalink
Use the newly-standard .toSorted method
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Jul 2, 2023
1 parent 84a7c3e commit ec1ed49
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/block-editor/src/utils/sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ const comparator = ( field, order ) => {
* @return {Array} Sorted items.
*/
export function orderBy( items, field, order = 'asc' ) {
return items.concat().sort( comparator( field, order ) );
return items.toSorted( comparator( field, order ) );
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function mapMenuItemsToBlocks( menuItems, level = 0 ) {
let mapping = {};

// The menuItem should be in menu_order sort order.
const sortedItems = [ ...menuItems ].sort(
const sortedItems = menuItems.toSorted(
( a, b ) => a.menu_order - b.menu_order
);

Expand Down

0 comments on commit ec1ed49

Please sign in to comment.