https://i.sstatic.net/SgDDc.png
I need to display a list sorted by signature date. If the signature date is not past-dated or missing, the record is considered active and should be sorted first alphabetically. Inactive records should come after active ones in alphabetical order. I have managed to sort based on name but struggling to push inactive dates to the end.
Check out the attached DEMO for reference.
const employee = [
{
name: 'jpat',
signatureDate: '',
businessType: 12346,
originalFileName: 'hello.xls',
agentW9id: 11,
fileName: 'hello.xls',
agentCode: 0,
class: '',
status: '',
},
{
name: 'jcar',
signatureDate: '09/10/2021',
businessType: 12346,
originalFileName: 'test.xls',
agentW9id: 12,
fileName: 'test.xls',
agentCode: 0,
class: '',
status: '',
},
{
name: 'Test',
signatureDate: '09/23/2020',
businessType: 12346,
originalFileName: 'test.xls',
agentW9id: 13,
fileName: 'test.xls',
agentCode: 0,
class: 'inactive',
status: 'Inactive',
},
{
name: 'newTest',
signatureDate: '10/9/2020',
businessType: 12346,
originalFileName: 'test.xls',
agentW9id: 13,
fileName: 'test.xls',
agentCode: 0,
class: 'inactive',
status: 'Inactive',
},
{
name: 'abc',
signatureDate: '10/29/2021',
businessType: 12346,
originalFileName: 'test.xls',
agentW9id: 13,
fileName: 'test.xls',
agentCode: 0,
class: '',
status: '',
},
{
name: 'djhfj',
signatureDate: '',
businessType: 12346,
originalFileName: 'test.xls',
agentW9id: 13,
fileName: 'test.xls',
agentCode: 0,
class: '',
status: '',
},
];
console.log(employee.sort((a, b) => (a.name > b.name ? 1 : -1)));