Sorting negative numbers

QuestionsSorting negative numbers
Vygandas asked 6 months ago

Hello,

In version 2.6 when sorting DESC,
-5 is higher than 0, which is mathematically false! (0 > -5)
Should be (-5 < 0)

View post on imgur.com

6 Answers
Abu Ghufran Staff answered 6 months ago

Sorting is done by database ORDER BY clause, so make sure your field is numeric in order to sort numerically. If field is varchar, it will sort alphabetically. If it does not solve, please reopen ticket.

_________________________
Abu Ghufran - Dev Team
PHP Grid Framework
 
Vygandas answered 6 months ago

Nope. The same code, (in this case using “Load Array”).
When using v2.00 lib, works ok! https://imgur.com/a/Wl2U1z8

Column code:

$col = array();
$col[“title”] = “Saldo”; // caption of column
$col[“name”] = “{$row[‘partn_kodas’]}{$row[‘uzs_nr_skaita’]}_saldo”;
$col[“width”] = “70”;
$col[“sorttype”] = int;
$cols[] = $col;

Abu Ghufran Staff answered 6 months ago

I’ve emailed you latest build that is running on this working demo.

https://www.phpgrid.org/demo/demos/loading/load-array.php

_________________________
Abu Ghufran - Dev Team
PHP Grid Framework
 
Vygandas answered 6 months ago

Thank You.

Maybe You could add 0 to column quantity in demo ?

and then check again?

Because in my case 0 is higher that negative numbers. And that is incorrect of course.

 

Abu Ghufran Staff answered 6 months ago

I’ve regenerated this issue. will update back.

_________________________
Abu Ghufran - Dev Team
PHP Grid Framework
 
Abu Ghufran Staff answered 6 months ago

Hello,

Sorting will work with sorttype => number,

$col = array();
$col[“title”] = “Quantity”; // caption of column
$col[“name”] = “quantity”;
$col[“width”] = “100”;
$col[“sorttype”] = “number”;
$cols[] = $col;

Demo: https://www.phpgrid.org/demo/demos/loading/load-array.php

Code: https://www.phpgrid.org/demo/demos/loading/load-array.phps

_________________________
Abu Ghufran - Dev Team
PHP Grid Framework
 
Your Answer

2 + 2 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!