mirror of
https://gittea.dev/nova/th.git
synced 2025-10-22 02:40:15 -04:00
improvements to sort_rand
This commit is contained in:
16
sorting.c
16
sorting.c
@@ -103,21 +103,15 @@ int sort_alpha(const void *file0, const void *file1){
|
||||
char *file_name1 = ((file*)file1)->file_name;
|
||||
return strcmp(file_name0, file_name1);
|
||||
}
|
||||
int sort_random(const void *file0_, const void *file1_){
|
||||
file *file0 = (file*)file0_;
|
||||
file *file1 = (file*)file1_;
|
||||
if (file0->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR) && !(file1->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR))) {
|
||||
int sort_random(const void *file0, const void *file1){
|
||||
|
||||
if (((file*)file0)->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR) && !(((file*)file1)->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR))) {
|
||||
return -1;
|
||||
}
|
||||
if (!(file0->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR)) && file1->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR)) {
|
||||
if (!(((file*)file0)->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR)) && ((file*)file1)->file_type & (FILE_TYPE_SYMLINK | FILE_TYPE_DIR)) {
|
||||
return 1;
|
||||
}
|
||||
int random = rand();
|
||||
if (random & 1) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return ((rand()%3)-1);
|
||||
|
||||
}
|
||||
int sort_type(const void *file0, const void *file1){
|
||||
|
Reference in New Issue
Block a user