INTERACT FORUM

Please login or register.

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

Author Topic: Sorting expression results with HTML Font Properties  (Read 2635 times)

StFeder

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1493
  • Fight! You may win. If you don't, you already lost
Sorting expression results with HTML Font Properties
« on: February 26, 2014, 06:10:15 am »

I'm using an expression to calculate some data. I had some trouble but finally I got this working :)

Now I'm using some HTML Font Properties to format the output so I'm able to see some special results at a glance. The Problem for me is, that MC considers the font tag as a relevant value for sorting. So sorting my list doesn't give me this:

1
2
3
4
5
6
7
8
9

but this:

2
5
6
7
1
3
4
8
9

Maybe this makes sense in some cases, but I'd guess for most cases this isn't what a user wants. The use of colors should enable to distinguish values at a glance which is not necessary any more when they are already grouped.

Am I missing some expression switch to change this behavior, is it a bug, or is there no chance to change this because it work as expected?
Logged

SkGe

  • Galactic Citizen
  • ****
  • Posts: 424
Re: Sorting expression results with HTML Font Properties
« Reply #1 on: February 26, 2014, 08:58:52 am »

You should put at the end of the expression this:
Code: [Select]
&datatype=[list]
    It should list as from 1 to 10
Logged

StFeder

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1493
  • Fight! You may win. If you don't, you already lost
Re: Sorting expression results with HTML Font Properties
« Reply #2 on: February 26, 2014, 10:01:53 am »

Thanks for your reply, sirgeo, unfortunately it doesn't work. I tried every possible datatype, but non of them worked.

The expression I'm using is this one:
IfElse( IsEmpty( [BPM StFeder] ), <font color="F78181">[BPM calculated]<//font>, IsRange( Math( abs( replace( [BPM calculated], /,, .) - [bpm StFeder])), 0-3),[BPM calculated], 1, [BPM StFeder])

If I include the HTML Font properties (marked red above) I get a sorting as visible in screenshot 1 attached below. If I remove the formatting I get the expected order visible in screenshot 2.

Sidenote: if you look at the upper red square in screenshot 1 you'll see, that the sorting inside the red group also isn't correct. 41,5 is listed in front of 41. In screenshot 2 this doesn't happen. There 41 stands in front of 41,5 as it should.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Sorting expression results with HTML Font Properties
« Reply #3 on: February 26, 2014, 12:01:23 pm »

The solution is to create two fields; one with the HTML, one without.  Use the field without the HTML as the sort key.
Logged
The opinions I express represent my own folly.

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10738
Re: Sorting expression results with HTML Font Properties
« Reply #4 on: February 26, 2014, 12:08:18 pm »

Wouldn't it be smarter if it parsed the HTML formatting out before sorting? That seems like a good change, I think.
Logged
~ nevcairiel
~ Author of LAV Filters

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Sorting expression results with HTML Font Properties
« Reply #5 on: February 26, 2014, 12:13:13 pm »

Yup, and it has been asked for several times.  I think Matt's response was that sort was critical path, so he didn't want to slow down ops here.
Logged
The opinions I express represent my own folly.

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10738
Re: Sorting expression results with HTML Font Properties
« Reply #6 on: February 26, 2014, 01:53:03 pm »

Hm, I suppose that makes sense. I might dig up the code anyway and see whats up.
Logged
~ nevcairiel
~ Author of LAV Filters

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Sorting expression results with HTML Font Properties
« Reply #7 on: February 26, 2014, 02:38:33 pm »

Logged
The opinions I express represent my own folly.

StFeder

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1493
  • Fight! You may win. If you don't, you already lost
Re: Sorting expression results with HTML Font Properties
« Reply #8 on: February 26, 2014, 05:09:52 pm »

The solution is to create two fields; one with the HTML, one without.  Use the field without the HTML as the sort key.
Don't get this.

Do you mean creating two fields, one to be displayed and one set as sort field in the view settings?! If yes, it is a great workaround, but will not do the trick for me, because I have to change the sorting via clicking to the column header.

Or is there a possibility to use another field (the unformated one) inside the expression for sorting purpose and display the formated one?! That would be a solution but I don't know how to handle it...

Wouldn't it be smarter if it parsed the HTML formatting out before sorting? That seems like a good change, I think.
This of course would be GREAT  :D
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Sorting expression results with HTML Font Properties
« Reply #9 on: February 26, 2014, 05:15:14 pm »

Yes, that's the idea.  But in the view's Set rules for file display, select your non-HTML'd field as a sort key.
Logged
The opinions I express represent my own folly.

StFeder

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1493
  • Fight! You may win. If you don't, you already lost
Re: Sorting expression results with HTML Font Properties
« Reply #10 on: February 26, 2014, 05:24:20 pm »

Sorry for being that slow, but you are talking about putting the field without html into the red square in the attached screenshot so the view gets sorted using the non html field even without displaying it in the given view itself?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Sorting expression results with HTML Font Properties
« Reply #11 on: February 26, 2014, 05:30:43 pm »

You've got it.
Logged
The opinions I express represent my own folly.

StFeder

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1493
  • Fight! You may win. If you don't, you already lost
Re: Sorting expression results with HTML Font Properties
« Reply #12 on: February 26, 2014, 05:38:02 pm »

You've got it.
Yeah  8)

So it doesn't fill my needs. I must be able to hit a column header to change sorting. So if I set the sorting this way there is no way of going back to the "work-around-sorting".

It would be possible to use this if I deactivate Tools -> Settings -> Tree & View -> Save changes on list header clicks. Then I could hit the refresh button to revert the sorting. But this would lead to some other serious usability problems. I have to do some thinking about this ;)

Thanks MrC for taking the time!
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Sorting expression results with HTML Font Properties
« Reply #13 on: February 26, 2014, 05:39:30 pm »

You're welcome.  You could add that column to the view too, but make it very thin, or out of the way, so you can click it.
Logged
The opinions I express represent my own folly.

csimon

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1686
Re: Sorting expression results with HTML Font Properties
« Reply #14 on: February 26, 2014, 06:20:01 pm »

I LOL'd at this! It reminds of an occasion some time ago in work when I was given a spreadsheet of data by a user for uploading into a table, and the instruction was "I want all the items coloured yellow loaded but not the ones coloured red".

I was hoping for an extension to SQL that would select data where colour = "yellow"...

I just never thought I'd see data sorted by colour!
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Sorting expression results with HTML Font Properties
« Reply #15 on: February 26, 2014, 07:07:08 pm »

Couldn't you...

Make an expression column (or calculated field) that includes the sort data in the front, hidden by your clever hiding trick used for Grouping?

So, for track number, something like:

<font size="10" alpha="0" color="ffffff">[Track #]<//font><font My REAL STUFF HERE>[Track #]<//font>
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

StFeder

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1493
  • Fight! You may win. If you don't, you already lost
Re: Sorting expression results with HTML Font Properties
« Reply #16 on: February 26, 2014, 07:08:35 pm »

Believe it or don't: I was just trying this trick! Don't have it working right now, but I'm on my way :)
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Sorting expression results with HTML Font Properties
« Reply #17 on: February 26, 2014, 07:18:19 pm »

I think it is useful if the expression isn't too expensive.

For an expensive expression, it would might be advantageous to save the output to a global variable, and then output that variable with and without the HTML.  But GVs are expensive too, so...?
Logged
The opinions I express represent my own folly.

StFeder

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1493
  • Fight! You may win. If you don't, you already lost
Re: Sorting expression results with HTML Font Properties
« Reply #18 on: February 26, 2014, 07:49:26 pm »

Couldn't you...

Make an expression column (or calculated field) that includes the sort data in the front, hidden by your clever hiding trick used for Grouping?

So, for track number, something like:

<font size="10" alpha="0" color="ffffff">[Track #]<//font><font My REAL STUFF HERE>[Track #]<//font>

I finally used

<font size="5" color="1d2027">FormatNumber( [BPM calculated], 0)<//font>

The font size is the smallest MC is able to display (it's "5"), the color matches black on black. I had to use FormatNumber again, even after already using it inside the source field because some values have no decimal places and MC doesn't fill unused places with "0". Perhaps I could do some slight tuning at this point with removing the FormatNumber from the source field and only use it in the destination instead of using it twice.

I think it is useful if the expression isn't too expensive.

I didn't think of the costs of an expression. But after reading that, I did some quick benchmark (using my smartphone as a stopwatch). I saw differences about 20% in opening the view but I couldn't see a correlation to the visibility of my field. The field isn't used for any view or smartlist, it's only for being shown in the file list. So I think if this field causes a big impact I should have seen it in my high quality, science proofed evaluation ;)

For an expensive expression, it would might be advantageous to save the output to a global variable, and then output that variable with and without the HTML.  But GVs are expensive too, so...?

I have no idea how this should work. I never used global variables. Still a lot to learn, but for now I'm done and happy with the state I reached :)

Thanks again for all your input!
Logged
Pages: [1]   Go Up