Example #1
0
// comparison function for use with qsort
int cmp_score(const void *a, const void *b)
{
    match_t a_match = *(match_t *)a;
    match_t b_match = *(match_t *)b;

    if (a_match.score > b_match.score)
        return -1; // a scores higher, a should appear sooner
    else if (a_match.score < b_match.score)
        return 1;  // b scores higher, a should appear later
    else
        return cmp_alpha(a, b);
}
Example #2
0
File: utils.c Project: Thog/ft_ls
int		cmp_time(void *data1, void *data2, int type, int revert)
{
	t_file	*file1;
	t_file	*file2;
	int		result;

	result = revert ? -1 : 1;
	file1 = ((t_file*)data1);
	file2 = ((t_file*)data2);
	if (file1->date < file2->date)
		return (result);
	if (file2->date < file1->date)
		return (-result);
	if (file1->datensec < file2->datensec)
		return (result);
	if (file2->datensec < file1->datensec)
		return (-result);
	return (cmp_alpha(file1, file2, type, revert));
}