Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, April 18, 2024
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Sorting uses string sort instead of numeric

phpMyEdit General     Sorting uses string sort instead of numeric
Post new topic   Reply to topic    
 
vmehta211     Joined: 22 Nov 2007   Posts: 5  
Post Posted: 2007-11-22 00:13
Back to top  Reply with quote     

Hello,
I have a column type of int(11) and it stores a value (seconds). I use the sql option to recalculate lifetime into days. When I sort this column it sorts by string and not by the original value in the column. So 7.0 is larger then 32.0. This is not correct. I've read through this forum and have Google searched for solutions but could not find anything.
I need the sort to be performed on the original values using a numerical comparisons. Is this possible?


$opts['fdd']['lifetime'] = array(
'name' => 'Lifetime (days)',
'select' => 'T',
'escape' => false,
'sql' => 'CONCAT("<center>",ROUND((lifetime / 60 / 60 / 24), 1),"</center>")',
'maxlen' => 255,
'sort' => true
);

 
vmehta211     Joined: 22 Nov 2007   Posts: 5  
Post Posted: 2007-11-22 18:57
Back to top  Reply with quote     

I tried that mask suggesstion. It turned all the values into 00000.. I would like to tell myPhpEdit to use a numerical sort on the decimal value after it is calculated or it should perform the sort on the original value.

 
vmehta211     Joined: 22 Nov 2007   Posts: 5  
Post Posted: 2007-11-22 19:46
Back to top  Reply with quote     

Where would I find the call to a sorting function in the class file? I did a search and only found ksort under exec_triggers() and that does not seem like the right place to replace ksort with natcasesort().

 
vmehta211     Joined: 22 Nov 2007   Posts: 5  
Post Posted: 2007-11-22 20:01
Back to top  Reply with quote     

Maybe I don't understand how to use the mask option.

If I add 'mask' => '%011d' to the field options, I do not get the desired results. Am I missing something?

I wouldn't be opposed to hacking the class file but I am not sure how to approach this task. If anyone knows where to edit the class file or has another possible solution please post.

Thank you!

 
vmehta211     Joined: 22 Nov 2007   Posts: 5  
Post Posted: 2007-11-23 01:10
Back to top  Reply with quote     

I tried '%011s' and it does not seem to add 000s but it also does not sort correctly. 9.0 is still considered larger then 32.0

I'll try any suggestions made on this forum. I read on previous posts and other people had the same problem.

They only needed to change the type of field they were using to some numeric type. I am using int(11) so that shouldn't be a problem.

What other workarounds are there? I tried to concatenate the original numeric value to the beginning of i.e. <hidden val=value</hidden><center>ROUND(value/60/60/24,1)</center> thinking it might allow the string sort to work but it didn't.

Any other suggestions?

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy