@@ -44,6 +44,9 @@ use amalthea::comm::data_explorer_comm::RowFilterParams;
4444use amalthea:: comm:: data_explorer_comm:: RowFilterType ;
4545use amalthea:: comm:: data_explorer_comm:: RowFilterTypeSupportStatus ;
4646use amalthea:: comm:: data_explorer_comm:: SearchSchemaFeatures ;
47+ use amalthea:: comm:: data_explorer_comm:: SearchSchemaParams ;
48+ use amalthea:: comm:: data_explorer_comm:: SearchSchemaResult ;
49+ use amalthea:: comm:: data_explorer_comm:: SearchSchemaSortOrder ;
4750use amalthea:: comm:: data_explorer_comm:: SetColumnFiltersFeatures ;
4851use amalthea:: comm:: data_explorer_comm:: SetRowFiltersFeatures ;
4952use amalthea:: comm:: data_explorer_comm:: SetRowFiltersParams ;
@@ -866,7 +869,7 @@ impl RDataExplorer {
866869 /// - `params`: The search parameters including filters and sort order.
867870 fn search_schema (
868871 & self ,
869- params : amalthea :: comm :: data_explorer_comm :: SearchSchemaParams ,
872+ params : SearchSchemaParams ,
870873 ) -> anyhow:: Result < DataExplorerBackendReply > {
871874 let all_columns = & self . shape . columns ;
872875
@@ -893,25 +896,43 @@ impl RDataExplorer {
893896
894897 // Apply sort order
895898 match params. sort_order {
896- amalthea :: comm :: data_explorer_comm :: SearchSchemaSortOrder :: Original => {
899+ SearchSchemaSortOrder :: Original => {
897900 // matching_indices is already in original order
898901 } ,
899- order => {
900- let ascending = matches ! (
901- order,
902- amalthea:: comm:: data_explorer_comm:: SearchSchemaSortOrder :: Ascending
903- ) ;
902+ SearchSchemaSortOrder :: AscendingName => {
904903 matching_indices. sort_by ( |& a, & b| {
905- let ord = all_columns[ a as usize ]
904+ all_columns[ a as usize ]
906905 . column_name
907- . cmp ( & all_columns[ b as usize ] . column_name ) ;
908- if ascending { ord } else { ord. reverse ( ) }
906+ . cmp ( & all_columns[ b as usize ] . column_name )
909907 } ) ;
910- }
908+ } ,
909+ SearchSchemaSortOrder :: DescendingName => {
910+ matching_indices. sort_by ( |& a, & b| {
911+ all_columns[ b as usize ]
912+ . column_name
913+ . cmp ( & all_columns[ a as usize ] . column_name )
914+ } ) ;
915+ } ,
916+ SearchSchemaSortOrder :: AscendingType => {
917+ matching_indices. sort_by ( |& a, & b| {
918+ all_columns[ a as usize ]
919+ . type_name
920+ . to_lowercase ( )
921+ . cmp ( & all_columns[ b as usize ] . type_name . to_lowercase ( ) )
922+ } ) ;
923+ } ,
924+ SearchSchemaSortOrder :: DescendingType => {
925+ matching_indices. sort_by ( |& a, & b| {
926+ all_columns[ b as usize ]
927+ . type_name
928+ . to_lowercase ( )
929+ . cmp ( & all_columns[ a as usize ] . type_name . to_lowercase ( ) )
930+ } ) ;
931+ } ,
911932 }
912933
913934 Ok ( DataExplorerBackendReply :: SearchSchemaReply (
914- amalthea :: comm :: data_explorer_comm :: SearchSchemaResult {
935+ SearchSchemaResult {
915936 matches : matching_indices,
916937 } ,
917938 ) )
0 commit comments