how to make button to sort array of objects alphabetical javascript react

trying to create a button in the component that sorts the array of objects by each objects name alphabetically and renders in component when clicked

menuItems = [{name: pizza}, {name: burger}]
class MenuItems extends Component {

    handleclick = (item) => {

        return ( 
                <button onClick={this.handlechange}>filter a to z</button>
                { =>(
                    <li class="list" key={}>
                        <img src={item.image}></img>
                        <button id={} onClick={() => this.handleclick(item)}>delete </button>


export default connect(null, {deleteMenuItem})(MenuItems)```


you could try this

menuSort = () => {
const newMenuItems = { ...this.props.menuItems };
newMenuItems.sort((a, b) =>;
this.setState({MenuItems: newMenuItems });

The localeCompare() method returns a number indicating whether a reference string comes before, or after, or is the same as the given string in sort order.

then use MenuItems in your render function, like you already have