Hi I am trying to sort integer value from highest to lowest.
I was able to get the sort result on my console log but I have noticed that the 100 value is not sorted as being the highest value. BUT before that happens the zero values are “null” , it was inserted without an integer value. So i changed it to zero and i tried inserting again 100 data value. But it wont sort 100 value as the highest value.
Aha - looks like it’s being sorted as text. Don’t understand.
Please post the Editor URL of your site, indicate which collection, and I’ll take a look.
Edited: (removed by me)
Collection name: enrolledStudents
Collection fieldName: generalAve
FieldType was already set to Number before I STARTED entering data, then input box was also set to number. I even tried converting the input value into a number still not able to sort 100 the highest value.
@yisrael-wix There was this problem before that i forgot to store a default “no value” which it must be a “0” integer and the system enters a “null” value. So I tried to manually overwrite it with an integer value which is 100. Im not sure that will affect the value type =x I also tried entering a 100 value again insert it to my collection, I also manually updated my previous data value to a 100 and to check if it can be sorted as 100 the highest but it is still cant.
Do we always need to convert the input value to a number even if you set your inputbox to number only before storing it to a field which its type is a number?
1st console log result is a TEXT value
2nd console log result is a NUMBER value.
Thank you! I Hope I’ll be enlightened with this issue.
Yep, value always returns text. Setting an input field to Number just defines the behavior of the field, but not the type of the return value. This might be your problem.
Also, sorry I hadn’t responded earlier. For some reason I’m unable to access your database collections. I think it’s an internal permissios issue that I’m trying to resolve.
Thank you for the clarification about input value always returns as text value. Still I dont know why my generalAve field cant sort 100 as the highest value. I tried my age_field i manually entered a integer value on a number type field and IT CAN sort 100 as the highest but my generalAve still cant sort 100 as the highest value. =x Should I create a new generalAve field? =x But i wish to know how come database got this problem so i can avoid this problem on the future. Maybe by converting an input value to a number before inserting it to a database collection field type number.
@jeffersonuy Does the sort work correctly in the code? It might be bug in the Content Manager. I’m discussing this with QA. It does seem strange.
It might be that the column was corrupted with a mix of text and numbers and that’s causing the problem. In my opinion, that’s also a bug, but at least it might explain why this is happening.
So, you might want to try creating another column to test.
@yisrael-wix Yes when I sort it using a code it doesn’t sort according to highest value, so i check my collection and sort it within the content manager and i found out it doesn’t sorted. It might be corrupted with a mix of text and numbers =x
And I tried making a new column ( generalAve2 ) and it works perfectly. 100 is the highest number when sorted.
Maybe the generalAve column is corrupted =x
@jeffersonuy I hope this gets things working for you. Thanks for being patient.
As I said, I’ve sent this on to QA. Hopefully they can reproduce the problem.
@yisrael-wix Thank you. And I must be cautious now when inserting a value to a field number to avoid possible problem like this. I must convert it first to integer from text/string.