Eval column not sorting properly

have eval column 'Age' that does not sort properly:

am using

if (operation == "sort")
	return Age(modifieddate);

but it is not sorting the same as the modified column.

here is the eval column

<?xml version="1.0"?>
<evalcolumn align="2" attrrefresh="yes" autorefresh="yes" blurrable="no" category="date" customgrouping="no" foldertype="all" header="Age - Days (Modified)" keyword="Agemodified" maxstars="5" namerefresh="yes" nocache="yes" refreshtime="0xea60" reversegroups="no" reversesort="no" supportmarkup="no" title="Age - Days (Modified)" type="0">if (operation == &quot;sort&quot;)
	return Age(modifieddate);

date_now		= Now();
when_created 	= modifieddate;

mins	= Age(when_created, &quot;n&quot;);
hours	= Age(when_created, &quot;h&quot;);  // buggy
hours 	= Abs(mins / 60);
days	= Age(when_created, &quot;d&quot;);
weeks 	= Age(when_created, &quot;w&quot;);
months 	= Age(when_created, &quot;m&quot;);
years 	= Age(when_created, &quot;yyyy&quot;);

return_value = &quot;---&quot;;

if (mins &lt; 0) // for dates set in the future
  {
	return &quot;Future&quot;;
  }
elseif (days &gt;= 365)
  {
    return years &gt; 1 ? years + &quot; years&quot; : years + &quot; year&quot;;
  }
elseif (hours &gt;= 24)
  {
    return days &gt; 1 ? days + &quot; days&quot; : days + &quot; day&quot;;
  }
elseif (hours &gt; 0) 
  {
    return_value 	= hours &gt; 1 ? hours + &quot; hours &quot; : hours + &quot; hour &quot;;
	mins_left_over 	= mins - (hours * 60);
    return_value 	+= mins_left_over &gt; 1 ? mins_left_over + &quot; minutes&quot; : mins_left_over + &quot; minute&quot;;
  }
elseif (mins &gt; 0)
  {
    return_value = mins &gt; 1 ? mins + &quot; minutes&quot; : mins + &quot; minute&quot;;
  }
else
  {
    return_value = &quot;0 minutes&quot;;
  }

return return_value;
</evalcolumn>

Age(modifieddate) returns days. Try Age(modifieddate, "s") to get seconds.

Still not working :frowning: getting this result for

if (operation == "sort")
	return Age(modifieddate, "s");

Your column is set to Text type, so it'll do a text sort by default.

This should fix things:

if (operation == "sort")
	return Age(modifieddate, "s") as int;

Actually, my test set works fine even with Age(modifieddate).

:thinking:

May be luck, since Age(modifieddate) will return 0 for all/most of those.

Awesome, fixed, thanks for looking into it :slight_smile:

Ah, yes, I hadn't shuffled the files enough :blush: