Questions tagged [sort]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
9
votes
3answers
14k views

sorting columns in pageblocktable

I came across a reusable visualforce component to sort columns in pageblocktable.It works great on other browsers but not in IE and also sorting on currency fields is not working.Has anyone used it? ...
7
votes
1answer
3k views

How to sort Map by values

I need to loop through Accounts and then on all of the Contacts for those Accounts. I need to find what is the address with the most occurrences in Contacts for each Account and update the Account ...
7
votes
2answers
166 views

Significant elapsed time differences when calling sort() on different Comparable implementations

Before I dive into a bit of code, a summary of my question is: does anybody know what Salesforce does internally when calling .sort() on a List of custom classes? Scenario: I have a wrapper class ...
6
votes
2answers
226 views

SOQL with ORDER BY and NULLS LAST ASC return wrong order results when we order by field from relationship

I noticed that SOQL with ORDER BY and NULLS LAST ASC returns results in wrong order (especially when I order by field from relationship). I wonder if it is some kind of bug or I've done some mistake ...
5
votes
1answer
1k views

Apex equivalent of Java Comparator

I already know about the equivalent of Comparable - the class to be sorted should implement Comparable and then you can sort a List of said class. But, how about Comparator? In java, the Collections....
5
votes
1answer
898 views

Sort with field of type String containing numbers and letters both

What is the best way to sort a List of String containing letters and numbers as values? I have tried couple of ways to sort, but with nothing I could make it work. Using a sort method of list Using ...
5
votes
2answers
1k views

apply sorting in apex repeat tag

I'm new in Salesforce. I've created a custom field (type text (10) ) in accounts. I want to group accounts by text (level 1, level 2, level 3) and add drag and drop to move account in groups. Thank ...
4
votes
1answer
4k views

How to sort keys in MAP while grouping

I am trying to insert list of wrapper class records in a MAP taking group name as KEY and related Wrapper class records as value pair . the wrapper classes were public class SCQLWrapperClass { ...
4
votes
1answer
107 views

Can I change Product lookup sort order?

I would like my Product lookup to list by Product CODE and not by Name, as it is now. It seems I cannot do that as I get an error saying 'Error: Product Name cannot be removed and must be the first ...
4
votes
1answer
3k views

Map<Id,List<CampaignMember> Where Key is a different SObject

I'm trying to find a way to populate a Map<Id,List<SObject>> Where the key is an Id of a different SObject. Specifically, I'd like to return campaign members associated with contacts at an ...
3
votes
1answer
239 views

Notes & Attachments Wrapper class not sorting by LastModifiedDate correctly

I am using the below code with the Comparable interface to build a combined list of all the attachments and notes on a record, sorted in descending order of LastModifiedDate (in constructor of main ...
3
votes
1answer
736 views

Sort wrapper list in Apex based on Levels

I have created a wrapper which contains an account record and a string describing the level of account Platinum, Gold, Silver. public class PartnerWrapper implements Comparable { public Account ...
3
votes
1answer
180 views

Wrapper class sorting where sort is not lexicographical

I've seen a couple of questions regarding sorting a Wrapper class, but I don't believe any meet my requirements. (Please correct me if I'm wrong) So I've implemented sorting for my wrapper class, and ...
3
votes
1answer
2k views

Custom sObject sorting with 'implements comparable'

I'm trying to perform a sort on a list of custom sObjects using the 'implements comparable' wrapper method. I'm running into some error that it seems isn't affecting anyone else. My custom object ...
3
votes
1answer
294 views

What controls the sortDirection arrow in lightning-datatable?

I have a lightning-datatable (lwc) that has a number of columns that are sortable. I'm tracking the sort direction of each column with a separate variable. The sorting works great, including ...
3
votes
1answer
1k views

Apexpages.currentPage().getUrl() is not returning the exact order of url params

I have implemented a code to get a URL parameters posted on custom site.The controller associated with custom site has Apexpages.currentPage().getUrl() method. For my implementation, It is very ...
3
votes
0answers
77 views

Does List<SObject>.sort method implementation depend on version?

I believe that I have found very interested undocumented bug in Salesforce. I don't see in the documentation saying that List.sort method implementation depends on version, but looks like it does. If ...
2
votes
1answer
142 views

Descending Table With Two Objects

I have a table that lists out two different objects in descending order. The issue is that the list is returning all of one object and then all of the second object. It is still in one table but the ...
2
votes
1answer
155 views

Sort a list of tasks by date value

I'm trying to sort a list of tasks by their due date in ascending order. I've looked in a couple of forums and none are what I exactly need. I'm sure this should be relatively easy but haven't found ...
2
votes
2answers
304 views

Cannot sort on numeric field with SOQL in Custom Metadata

Cannot sort on a soql-request in a custom meta data type. When i perform SELECT .. FROM x__mdt WHERE ... ORDER BY x. Then field x cannot be numeric to get a correct order. Change it to a string-field ...
2
votes
1answer
54 views

Wrapper List Sort by 2 text values

I have a wrapper class with 2 text values. I sorted them using Comparable. It works fine for one value. Here, I have AreaName and ADName. With the below I'm able to successfully sort by AreaName. ...
2
votes
1answer
2k views

Sorting apex:pageblocktable

I was wondering if someone has used the PageBlockTableEnhancerADV plugin and was able to implement sorting function for each column. I was trying to use the www.datatable.com sorting plugin but I can ...
2
votes
1answer
57 views

My bubble sort seems to be prioritizing one object over the other. and not actually sorting by createdDate. Can anyone tell why?

I am using a bubble sort to sort two different objects I have within a list. Right now it seems to be putting the Knowledge articles before the Events, and furthermore the Date is not sorting properly....
2
votes
1answer
761 views

Client side sorting based on Parent Fields

Client-side sorting in Lightning Component, In my component I have Parent Records as well, so I need to sort based on Parent Records also. Currently, I'm doing sorting on Server side but I want to do ...
2
votes
1answer
157 views

Is there a better way to order my collection?

I'm trying to display a chronological list of CaseHistory records to display case edits. I have the following code: public Map<CaseHistory,String> getHelpdeskHistory() { List<...
2
votes
1answer
394 views

Strange, slow behavior during ordering w/ REST API

I'm seeing some very bizarre SOQL performance when ordering by Id across several Sobjects. In this, they seem to take a very long time to select even just Ids when asked to sort by Id. Remove the ...
2
votes
0answers
78 views

Sort Products on QuoteLineItems

I am using Salesforce API 27 in .net tool to sync quote and opportunity from external system. However quote in external system and salesforce has not the same order. Salesforce is performing sorting ...
1
vote
3answers
2k views

How to sort a list of strings in the descending order?

I'm trying to sort the list of strings which has versions but fail to do this: List<String> src = new List<String>{'7.1.2', '8.1.3', '11.0.5', '5.x', '10.0.89', '12.13.14'}; List<...
1
vote
1answer
905 views

Illegal assignment from void to LIST<>

I am trying to sort a list of sObjects using compareTo method example. Getting the error a mentioned in the tittle. Code below: public inputnulls(ApexPages.StandardSetController controller) { ...
1
vote
2answers
378 views

Sort a Map values apex [duplicate]

I have a map of Map<String,Decimal> test = new Map<String,Decimal>(); In this map i am adding values like classname and codepercentagecovered and iterating over the map and creating ...
1
vote
1answer
2k views

How to sort a wrapper class list which has a reference to another wrapper in it

I want to sort a wrapper class list which has a reference to another wrapper in it.I tried implementing Comparable interface for both of class but it is showing error One or more of the items in ...
1
vote
1answer
413 views

Lightning client side sorting (using a separate function, not inline)

I'm trying to implement a sorting function for the records returned by a callback. The normal javascript a.value - b.value inline implementation is working. This is the working code that I have: /...
1
vote
2answers
207 views

ERROR: Dynamic sorting in Wrapper class' column header

I have implemented a Wrapper class using this: Salesforce Wrapper Class. Now I am trying to implement sorting for the column header which turns out to be throwing error: Invalid field Account.Name ...
1
vote
1answer
743 views

Natural sorting(Text with Numbers) for String in Apex [closed]

I must sort strings like "Text x.x.x(Text x)", "Text x.x.x", etc.(where x - number) in right way in Apex. Something like that: Input - ['Test 1.2(V 1000)', 'Test 1.10(V 1001)', 'Test 1.2(V 1001)', '...
1
vote
1answer
2k views

Bootstrap table sorting not working for inputfield

I have used a Bootstrap datatable to show records in a tabular format as shown below And here is the simple code for the above page <style> input[type="text"] { display: ...
1
vote
1answer
326 views

Aura:iteration with Data Tables and setting the order to descending as rows are inserted

So we have a client that has a form page where a Data Table is built based on input. As they enter items the table sorts them by index (i'm assuming) in ascending order. Without making the user sort ...
1
vote
1answer
264 views

Can we sort report columns using Report API via APEX? I found this on the document 'Reports.ColumnSortOrder' but there's no example

I have the below codes to get and run report using Reports API via apex but I need to the sort the first column of the report. List <Report> reportList = [SELECT Id,DeveloperName FROM Report ...
1
vote
1answer
376 views

Custom Open Activities Inline Vf page with sort functionality

As we cannot sort open activities but on Go to List link page we can sort on any field ( Go To link appears if there are more than 5 records..this is standard functionality) .so I've built a custom ...
1
vote
0answers
32 views

'Sort By' changes dashboard in metadata

I have a dashboard with unchecked 'Use chart settings from report'. I changed the field in Sort By options and can't find these changes in Dachbord metadata. Where can I find 'Sort By' changes in ...
1
vote
2answers
46 views

Sort AlphaNumeric versions

How to sort the Version(i.e) '1.4.7','5.19.0','5.18.0','5.14.1','5.8.1','5.8.2','5.20.1','5.20.0' something like this. Initially tried with splitting by DOT and then comparing the First value in a ...
1
vote
1answer
86 views

problem with sorting Quote

I have following custom quote page and controller but the problem is sorting is not working properly, When i click on column for sorting ascending and descending it will not show me the list with ...
1
vote
1answer
184 views

How can we sort wave report by number column?

I have created a Wave Report which I need to sort by Number field. I am not able to add Formula(Number) in Group by column even with using SAQL. I have already tried the workaround to change Formula(...
0
votes
4answers
433 views

Decrement Max Value From Map?

How can I sort a Map based on value? Here is the Map structure: Map<DateTime, Integer> AppDetails = new Map<DateTime, Integer>(); And the data: 2016-10-1,10 2016-10-2,3 2016-10-3,...
0
votes
1answer
35 views

Sorting a List of different object Lists by datetime

I have a List<ListWrapper> comprised of List<Knowledge__kav> and List<Community_Event__c>. I would like to sort List<ListWrapper> by date but the two inner lists have different ...
0
votes
1answer
136 views

How to sort a dynamic picklist

I have a visualforce page where I am displaying dynamic picklist Visualforce code: <apex:selectList value="{!SelectedNomination}" size="1" id="a"> <apex:selectOptions value="{!...
0
votes
2answers
1k views

compareTo method not sorting result in list

I have created attachment info object and using wrapper class to store attachment related information. I have created visual force page to display attachment with attachment information using wrapper ...
0
votes
1answer
207 views

How to sort formula showing Image in List View

I have a simple formula field in salesforce which show particular image based on another picklist, as below. IMAGE(IF(ISPICKVAL(Rating__c,"1 Star"), "/img/samples/stars_100.gif", IF(ISPICKVAL(...
0
votes
1answer
588 views

Sorting a keySet

I have a list that I created with a Wrapper Class and a Comparable/compareTo method. So it is sorted the way I would like it. From this list I created a Map with the key being the list's Created Date. ...
0
votes
1answer
61 views

Dynamic sorting in related lists in Salesforce classic

It seems I can't change the sorting order of a related lists inside the Account layout. Is it possible to allow the user to change the sorting column of a related list without "going to list" ?
0
votes
2answers
3k views

Get max(field) from List of sObject in salesforce

I have List of Records for which I want to find out Maximum value for particular Field: Can anyone suggest me, any efficient way (rather than writing Sorting Method) Example : public decimal ...