{
const char *sa = *(const char**)a;
const char *sb = *(const char**)b;
- infomsg("cmp(%s, %s)\n", sa, sb);
- return strcmp(sa, sb);
+ int isdir_a, isdir_b;
+
+ isdir_a = sa[strlen(sa) - 1] == '/';
+ isdir_b = sb[strlen(sb) - 1] == '/';
+
+ if(isdir_a == isdir_b) {
+ return strcmp(sa, sb);
+ }
+ return isdir_a ? -1 : 1;
}
void updateui(void)
ent = ent->next;
}
- //tui_sort_list(uilist, cmpnames);
+ tui_sort_list(uilist, cmpnames);
tui_list_select(uilist, 0);
ftp->modified &= ~FTP_MOD_REMDIR;
void tui_sort_list(struct tui_widget *w, int (*cmpfunc)(const void*, const void*))
{
+ int nelem;
struct tui_list *wl = (struct tui_list*)w;
assert(wl->type == TUI_LIST);
if(!cmpfunc) {
cmpfunc = (int (*)(const void*, const void*))strcmp;
}
- qsort(wl->entries, darr_size(wl->entries), sizeof *wl->entries, cmpfunc);
+
+ nelem = darr_size(wl->entries);
+ qsort(wl->entries, nelem, sizeof *wl->entries, cmpfunc);
}
static void draw_list(struct tui_widget *w, void *cls)