code: public void sortGalleries(String sortParams, String filter) {
  
          List<CmsGalleryFolderBean> galleries;
          if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(filter)) {
              galleries = new ArrayList<CmsGalleryFolderBean>();
              for (CmsGalleryFolderBean galleryBean : m_dialogBean.getGalleries()) {
                  if (galleryBean.matchesFilter(filter)) {
                      galleries.add(galleryBean);
                  }
              }
          } else {
              galleries = m_dialogBean.getGalleries();
          }
          SortParams sort = SortParams.valueOf(sortParams);
          switch (sort) {
              case title_asc:
                  Collections.sort(galleries, new CmsComparatorTitle(true));
                  break;
              case title_desc:
                  Collections.sort(galleries, new CmsComparatorTitle(false));
                  break;
              case type_asc:
                  Collections.sort(galleries, new CmsComparatorType(true));
                  break;
              case type_desc:
                  Collections.sort(galleries, new CmsComparatorType(false));
                  break;
              case path_asc:
                  Collections.sort(galleries, new CmsComparatorPath(true));
                  break;
              case path_desc:
                  Collections.sort(galleries, new CmsComparatorPath(false));
                  break;
              case tree:
                  m_handler.onUpdateGalleryTree(galleryListToTree(galleries), m_searchObject.getGalleries());
                  return;
              case dateLastModified_asc:
              case dateLastModified_desc:
              default:
                  // not supported
                  return;
          }
          m_handler.onUpdateGalleries(galleries, m_searchObject.getGalleries());
      }
docs: Sorts the galleries according to given parameters and updates the list.<p>
  
  @param sortParams the sort parameters
  @param filter the filter to apply before sorting