Index: core/filter_api.php =================================================================== --- core/filter_api.php (revision 5719) +++ core/filter_api.php (working copy) @@ -832,6 +832,8 @@ for( $i = 0;$i < count( $t_sort_fields );$i++ ) { $c_sort = db_prepare_string( $t_sort_fields[$i] ); + $c_dir = 'DESC' == $t_dir_fields[$i] ? 'DESC' : 'ASC'; + if( !in_array( $t_sort_fields[$i], array_slice( $t_sort_fields, $i + 1 ) ) ) { # if sorting by a custom field @@ -849,9 +851,11 @@ $p_query_clauses['join'][] = "LEFT JOIN $t_custom_field_string_table $t_cf_table_alias ON $t_bug_table.id = $t_cf_table_alias.bug_id AND $t_cf_table_alias.field_id = $t_custom_field_id"; } - $c_dir = 'DESC' == $t_dir_fields[$i] ? 'DESC' : 'ASC'; $p_query_clauses['order'][] = "$c_cf_alias $c_dir"; } + else { + $p_query_clauses['order'][] = $c_sort . " " . $c_dir; + } } }