Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sort]

The tag has no usage guidance.

2
votes
1answer
26 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 ...
0
votes
1answer
27 views

The sort function is not working properly

I have the following Array of results in contactArray attribute. Here What I need is I'll need to sort the following records by LastModifiedDate of a particular record. In the front end I have 3 ...
1
vote
1answer
32 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 ...
0
votes
0answers
27 views

How to Sort Opportunity Product Records in Lightning

In Classic, the Sort button is quite useful on the opportunity product so end user can easily adjust the order to present on the frontend or in generated document. But in Lightning the button is not ...
0
votes
0answers
39 views

how to do multiple coloumn sorting dynamically?

I want to do sorting in multiple coumns like. i am able to do sorting on one column click in complete table but not able to do sorting different columns in different sections. like this is my data ...
0
votes
0answers
23 views

how to sort different different wrapper list dynamically?

i want to sort the wrapper class where i have different different list of wrapper class. i want to do the sorting that different different wrapper list hold different different value, i am able to do ...
0
votes
0answers
60 views

How to sort a wrapper class in client side javascript in lightning

I have a wrapper class (contains Opportunity object as a variable and other Integer and String variables) which is iterated inside a table in lightning component. Columns in table --> Opportunity ...
1
vote
3answers
883 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<...
0
votes
1answer
119 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(...
6
votes
2answers
173 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 ...
0
votes
2answers
71 views

Apex Keyset- Sort values in DESC order while binding to picklist

I am trying to sort values in desc order before binding these to picklist. I have referred to some posts regarding sorting(This post) and implemented the below: Take keySet() of the map. Convert ...
0
votes
1answer
173 views

Sort field set in Visualforce renderAs PDF with apex:repeat

Can anyone help me to sort a field set that I'm iterating through with apex:repeat? I have a Visualforce page that renders some data as a PDF using Field Sets and I just want the ability to sort the ...
1
vote
2answers
262 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
274 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: /...
0
votes
0answers
22 views

Order by if data is same for a field

In visualforce page which use apex:repeat, and also for client side sorting uses datatable.js. A field column with date type is shown. Also the page allows inline editing, on successful edit it will ...
0
votes
1answer
95 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
1answer
76 views

apex:repeat group by/filter by field, show only unique values

So I have an SOQL query which returns an object with these fields: |Product Name|Option|Category| Category could be: A B Options could be: 1 2 3 In my VisualForce page I would like to visualise ...
1
vote
2answers
158 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 ...
2
votes
1answer
526 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 ...
0
votes
0answers
93 views

Sort Related List according Boolean formula field

In my account page I present all the account products. Each product object has custom boolean filed - formula type. This formula calculate if the product license is valid or not. In the GUI - there ...
2
votes
1answer
99 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 ...
3
votes
1answer
681 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 ...
1
vote
1answer
67 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
119 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
1answer
424 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. ...
6
votes
1answer
2k 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 ...
0
votes
2answers
761 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
157 views

Sort Order In OpportunityLineItem Preview

We have Sort button in OpportunityLineItem. Using this, customer may able to sort the products in the order they want, but in Preview (Visualforce page preview) it's dispaying default order (...
0
votes
0answers
14 views

Trying to sort on 2 field for wrapper list. First on dueDate then on timeAllocated. Im having trouble with the CompareTo [duplicate]

global class TimeSortWrapper implements comparable { public TableData timeObject; public TimeSortWrapper(TableData t) { timeObject = t; } global Integer compareDate(Object ...
0
votes
1answer
53 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
1answer
634 views

Bubble sort with Number field in Wrapper Class List

I would need some idea on how to sort a number column in Wrapper class. Wrapper class list is received from Callout and not by querying any SoBject. So cannot use ASC/DESC. Tried out comparable ...
0
votes
0answers
45 views

Products to opportunities, and the SortOrder field

While adding products to an opportunity in Salesforce, you can not specify the values for the 'SortOrder' field on Opportunity Line Items. That is very weird, and is a feature requested more than 7 ...
1
vote
1answer
222 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 ...
2
votes
2answers
204 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
133 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<...
1
vote
1answer
642 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)', '...
4
votes
1answer
100 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 ...
3
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 ...
0
votes
4answers
365 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,...
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 ...
3
votes
0answers
72 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
126 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 ...
0
votes
3answers
913 views

Sort List in Descending Order by BMCServiceDesk__date__c or CreateDate

I am working on a custom controller to sort the below apex:repeat list in Desc order by BMCServiceDesk__date__c or CreatedDate. Part of my VF email template and Controller code is below. I am ...
7
votes
2answers
153 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 ...
0
votes
2answers
2k 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 ...
0
votes
1answer
88 views

SOQL not working

I have a dynamic SOQL query where in I am using order by clause.I want to sort it by product Style SOQL soql = 'select id, name,Warehouse__c,Product_Reference__r.gii__ProductStyle__r.name, ...
4
votes
1answer
234 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
155 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
979 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 ...
5
votes
1answer
820 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 ...