data hook age field not sorting correctly

I am new to coding and need some assistance. I used the following data hook to formulate the age (in hours) since the last Updated Date for each record. The age (in hours) does populate correctly into the database. However, when I sort the “age” field from high to low, or vice versa it does not sort correctly. See screenshot of sort below. My ultimate goal is to have the age field sort numerically from high to low or viceversa.

export function Refer_Client2_afterQuery(item, context) {
item.age = ageFromLastUpdatedDate(item._updatedDate);
return item;
}
function ageFromLastUpdatedDate(_updatedDate) {
const now = new Date();
let age = ((now.getTime() - _updatedDate.getTime())/3600000);
return age;
}

1 Like