Created
February 12, 2019 10:55
-
-
Save kaleem-elahi/4a469c27bc06766e98cae17bbb779c36 to your computer and use it in GitHub Desktop.
To sort Job details date's with Present(Current) employer(company)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let final = []; | |
| const currentCompany = this.props.profile.position_history.filter(d => d.is_current_employer); // current company | |
| // Sorted latest to old job position | |
| const otherSortedComapny = this.props.profile.position_history.sort((a, b) => { | |
| if (a.end_date) { | |
| return new Date(b.end_date) - new Date(a.end_date); | |
| } | |
| return new Date(b.start_date) - new Date(a.start_date); | |
| }).filter(d => !d.is_current_employer); | |
| // Merge both and see the Magic | |
| final = [...currentCompany, ...otherSortedComapny]; | |
| console.log(final); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment