Title: Sorting
Last modified: February 8, 2022

---

# Sorting

 *  Resolved [johansam](https://wordpress.org/support/users/johansam/)
 * (@johansam)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/sorting-54/)
 * Is it possible to sort the output?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Pexle Chris](https://wordpress.org/support/users/pexlechris/)
 * (@pexlechris)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/sorting-54/#post-15342627)
 * How you mean? Do you want the folders first and then the files?
    The files first
   and then the folders? How do you think it? If you specify more details I can 
   give you the specific hook to do it with php
 *  Thread Starter [johansam](https://wordpress.org/support/users/johansam/)
 * (@johansam)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/sorting-54/#post-15342645)
 * For instance, I would like to sort on the file names in the file list. Or on 
   the file creations date. Or on the folder names.
 *  Thread Starter [johansam](https://wordpress.org/support/users/johansam/)
 * (@johansam)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/sorting-54/#post-15342670)
 * Have look at [https://mariefredbk.hemsida.eu/index.php/styrelseprotokoll/?dir=Styrelseprotokoll%2F2021](https://mariefredbk.hemsida.eu/index.php/styrelseprotokoll/?dir=Styrelseprotokoll%2F2021)
 * What if I want to show the files in revers order ie the newest file at the top?
 *  Plugin Author [Pexle Chris](https://wordpress.org/support/users/pexlechris/)
 * (@pexlechris)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/sorting-54/#post-15342727)
 * You can use the filter **lv_containing_files**.
    You can see in my documentation
   here: [https://www.pexlechris.dev/library-viewer/docs/hooks/?library-viewer=yes#lv_containing_files](https://www.pexlechris.dev/library-viewer/docs/hooks/?library-viewer=yes#lv_containing_files)
   in order to revert the array and return the reverted array.
 * You can use the php native function **array_reverse **.
    Doc here: [https://www.php.net/manual/en/function.array-reverse.php](https://www.php.net/manual/en/function.array-reverse.php)
 * Something like:
 *     ```
       add_filter('lv_containing_files', function($arr){
          $arr = array_reverse($arr);
          return $arr;
       });
       ```
   
 * In order to add the above hook in your site, read the following tutorial:
    [https://www.pexlechris.dev/how-to-add-php-hooks-in-your-wordpress-site/](https://www.pexlechris.dev/how-to-add-php-hooks-in-your-wordpress-site/)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Sorting’ is closed to new replies.

 * ![](https://ps.w.org/library-viewer/assets/icon-256x256.png?rev=2120573)
 * [Library Viewer](https://wordpress.org/plugins/library-viewer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/library-viewer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/library-viewer/)
 * [Active Topics](https://wordpress.org/support/plugin/library-viewer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/library-viewer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/library-viewer/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Pexle Chris](https://wordpress.org/support/users/pexlechris/)
 * Last activity: [4 years, 4 months ago](https://wordpress.org/support/topic/sorting-54/#post-15342727)
 * Status: resolved