You need to sign in to do that
Don't have an account?

sorting Text field problem.
Hello,
I have an requirement to sort Text field which contains (i.e. 0.0,0.1.0,0.0.0.1,1.0,1.1). it is the index of tree. i have another field which is Number field and it contains (0,1,2,3,...). i am making that above text field using this index field.
now i have an requirement to display that visualforce page as an HTML page. and that Text field i need to put infront of tree node name.e.g.
1.0 a1
1.1.0 a1.0
1.1.1 a1.1
i am using that text field so that it is sorting it by considering it String so my output becomes as follows which is wrong. can anyone help.
1 2.01.06.01 Australia Role Description 10 2.01.06.17 Spain Role Description 11 2.01.06.15 Portugal Role Description 12 2.01.06.19 United Kingdom & Ireland Role Description 13 2.01.06.02 Belgium Role Description 14 2.01.06.04 Czech Republic Role Description 16 2.01.06.10 India Role Description 17 2.01.06.12 Mexico Role Description 18 2.01.06.14 Poland Role Description 19 2.01.06.16 Slovenia Role Description 2 2.01.06.03 Canada Role Description 20 2.01.06.18 Switzerland Role Description 21 2.01.06.08 Hong Kong Role Description 3 2.01.06.05 France Role Description 4 2.01.06.07 Greece (Hellas Role Description 5 2.01.06.09 Hungary Role Description 6 2.01.06.11 Italy Role Description 7 2.01.06.13 Nordic & Baltic Region Role Description 8 2.01.06.06 Germany Role Description
Thank you,
Minkesh Patel
Thank you for you reply. you are right i have to do it in my apex and i did it. i have used json String so as per the JSON string name i have done sorting. here is the code
All Answers
You're going to need to manage this sorting yourself in Apex.
We don't have existing utilities that will help much other than list.sort() but that's only going to work for primitives so you'll need to manage the parsing.
Thank you for you reply. you are right i have to do it in my apex and i did it. i have used json String so as per the JSON string name i have done sorting. here is the code
Hi Minkesh.
I have similar issue. Please help me. I need to sort the id in descending order.
When the documents come from integration the id is ascendingorder by default. How can i display it in descending order.
public void createDocuments(JSONParser parser)
{
documentList = new List<Document>();
Document doc = new Document();
Integer position = 0;
while (parser.nextToken() != null)
{
if (parser.getCurrentToken() == JSONToken.START_OBJECT ||parser.getCurrentToken() ==JSONToken.END_OBJECT )
{
if(doc.title != null)// && doc.url != null && doc.rating != null && doc.filetype != null && doc.id != null && doc.description != null)
{
doc.position = position;
position++;
documentList.add(doc);
doc = new Document();
}
}
if (parser.getCurrentToken() == JSONToken.FIELD_NAME)
{
if(parser.getText() == 'title')
{
parser.nextToken();
doc.title = parser.getText();
}
if(parser.getText() == 'id')
{
parser.nextToken();
doc.id = parser.getText();
Pleas helo
Hello,
I am not able to understand your question.
You mean salesforce id ?