Q:

Reactjs - sort product array based on date

I want to sort date from the product array (date is one of the field in product). Please suggest me. I am using ReactJS.
Please find the code that am using.
render() {

          let sortedDate = this.state.item.sort((a, b) => Date.parse(new Date(a.expected_ship_date("/").reverse().join("-"))) - Date.parse(new Date(b.expected_ship_date("/").reverse().join("-"))));
          let sortedDate1 = this.state.item.sort((a, b) => new Date(a.expected_ship_date) - new Date(b.expected_ship_date));

        return (
            <tr>
                <td><input name="line_number" type="text" value={ this.state.item.line_number } disabled={ this.props.mode }  className="form-control" onChange={ this.handleInputChange }/> </td>
                <td><input name="requested_ship_date" type="date" value={ this.state.item.expected_ship_date } disabled={ this.props.mode }  className="form-control" onChange={ this.handleInputChange }  /></td>

                <td>{sortedDate.map( (c, i) => <div>{c.expected_ship_date}</div>)}</td>
            </tr>

        );
}

A:

For sorting you need to convert the date to epoch date, and then try to sort.
I suggest you should use moment to convert the date to epoch
Installation :
npm install --save moment

Code:
import moment from 'moment'

let sortedDate = this.state.item.sort((a, b) => moment(a.expected_ship_date).valueOf() - moment(b.expected_ship_date).valueOf());

