INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: [19.0.131] Custom sorting  (Read 1238 times)

Goatshade

  • Citizen of the Universe
  • *****
  • Posts: 651
[19.0.131] Custom sorting
« on: May 09, 2014, 01:45:11 am »

Is there a way to sort by a given library field in any order other than ascending or descending, particularly a custom order á la playlists? In my video section, I am currently sorting with [Media Sub Type] at the top level in descending order. What I want to do is define a custom order: TV Show, Movie, Short. Right now, it is Short, TV Show, Movie.

What do?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: [19.0.131] Custom sorting
« Reply #1 on: May 09, 2014, 02:16:02 am »

Yes.  I'll show you how tomorrow.
Logged
The opinions I express represent my own folly.

Goatshade

  • Citizen of the Universe
  • *****
  • Posts: 651
Re: [19.0.131] Custom sorting
« Reply #2 on: May 09, 2014, 02:33:15 am »

Okay. Thanks. :)
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: [19.0.131] Custom sorting
« Reply #3 on: May 09, 2014, 10:15:47 am »

Here's how you do it.

Since sorting is ASCII-betical, you need to create an expression that converts Media Sub Type values into a values that will sort the way you want.  You said you wanted:

   TV Show
   Movie
   Short

So let's assign them this way:

   1=TV Show
   2=Movie
   3=Short
   ...

and with that, we can use an expression to pull out the numerical values, which will sort the way we want:

   if(regex(1=TV Show; 2=Movie; 3=Short;, /#(\d+)=#/[media sub type];\s*), [R1], 100)

What we've done above is to create sort string, and pulled out only the part that matches the media sub type, along with its accompanying sort index.  For any MST you have not defined in the string, the sort value of 100 will be returned.  You can add additional values to the string above - the pattern should be obvious: #=<mst value>; and the trailing ; is important.

Create a new user field, of type expression and enter that expression as the Calculated data.  Name the expression something like _sort_MST.

Now you need to create a custom sort preset.  In any Standard View, go to the tab's pulldown, and select Sort By > Custom, and click the Add button.  From the a-z sort items, select your new field _sort_MST, and then save it as a Preset by clicking the Preset button.  Call it something like Media Sub Type (custom sort).  Once you have that saved, you can now use it instead of the limited Ascending, Descending, ... pre-defined sorts in the Category > Settings > Sorting pulldown.

You can work out your sort order in an expression column adjacent to a Media Sub Type column.  See attached.
Logged
The opinions I express represent my own folly.

nitephlight

  • World Citizen
  • ***
  • Posts: 142
Re:
« Reply #4 on: May 10, 2014, 12:53:31 am »

bookmarked- your wisdom will come handy one day surely
Logged

Goatshade

  • Citizen of the Universe
  • *****
  • Posts: 651
Re: [19.0.131] Custom sorting
« Reply #5 on: May 10, 2014, 06:14:11 am »

That worked perfectly! Thank you! :D
Logged
Pages: [1]   Go Up