Skip to content

Commit

Permalink
from Tom Ehlert, fix sort order when sorting by date AND time AND res…
Browse files Browse the repository at this point in the history
…ults compare identical, return sort by filename
  • Loading branch information
PerditionC committed Jan 3, 2022
1 parent facce56 commit fdf6907
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ static int DisplaySingleDirEntry(struct ffblk *file, struct currDir *cDir)
return cbreak? E_CBreak: rv;
}

/* return -1,0,1 where -1 if p1 is before p2, 0 if same, 1 if p2 is before p1 */
static int orderFunction(const void *p1, const void *p2)
{
int i1 = *(int*)p1;
Expand Down Expand Up @@ -972,9 +973,13 @@ static int orderFunction(const void *p1, const void *p2)
case ORDER_BY_NAME:
rv = strcmp(f1.ff_name,f2.ff_name);
break;
}
if (opt & ORDER_INVERSE) rv = - rv;
}
}
if (opt & ORDER_INVERSE) rv = - rv;
}

/* if criteria (size, date, etc) compare equal then return results lexically by filename */
if (rv == 0)
rv = strcmp(f1.ff_name,f2.ff_name);

return rv;
}
Expand Down

0 comments on commit fdf6907

Please sign in to comment.