Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

Questions tagged [comparable]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
11 votes
1 answer
2k views

System.ListException: One or more of the items in this list is not Comparable

I have an interface, MyInterface, that extends Comparable since I want to be able to sort lists of these objects: 1 global interface MyInterface 2 extends Comparable { All classes that ...
martin's user avatar
  • 12.7k
9 votes
3 answers
4k 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....
NickJ's user avatar
  • 680
4 votes
2 answers
885 views

Efficiently sorting a list of Work Order records by a Sequence

I have Work_Order_Sequence__c and UniqueKey__c field on Work Order object. In my method I wish to create a Map which has a Key => UniqueKey__c and Value=> List<WorkOrder> (sorted). ...
SfdcBat's user avatar
  • 4,811
4 votes
1 answer
2k views

Sort List of SObject in Wrapper Class

I have Wrapper class which contains List of Map. After performing some operations that List values order gets changed. public class TeacherAvailabilityWrapper{ public List<Session__c> ...
SFDC shaikh's user avatar
3 votes
1 answer
328 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 ...
Our Man in Bananas's user avatar
3 votes
1 answer
708 views

Implementing CompareTo In An Inner Class That Needs Outer Class Data

I'm using Apex and VisualForce to make an "open house event check-in page" for a department. For various reasons pertaining to AppExchange plugin compatibility, we are storing a separate "Event" ...
k..'s user avatar
  • 1,217
2 votes
4 answers
5k views

SOQL Error in Compare Date

Could you please help me for fix my SOQL Query? I have SOQL Scrip like : SELECT Employee_No__c FROM HREMPASSIGNMENT__c WHERE Payroll_Name__c=:selectedPayrollName AND Payroll_Name__c != null ...
Nicky's user avatar
  • 89
2 votes
1 answer
67 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. ...
sfdcFanBoy's user avatar
  • 4,064
1 vote
1 answer
233 views

Nested Compareable Methods on Wrapper Class

I have a wrapper of Tasks and Events that I want to sort by: ActivityDate then by LastModifiedDate then by CreatedDate (all in descending order) My initial thought was to do the comparable interface ...
Olivia's user avatar
  • 3,461
1 vote
1 answer
400 views

Problems implementing comparable class

I am trying to sort list x in descending order by Delta__c. I have been told that I should use a wrapper class and use the implements comparable class. I am getting the error even though Delta__c is ...
Mike's user avatar
  • 113
1 vote
2 answers
457 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 ...
SatyaV's user avatar
  • 1,523
1 vote
1 answer
493 views

Sorting of fields of custom object using comparable in a wrapper

I have a wrapper class which is sorted by the totalCount of the size of the three list (empSkillList, empTrainingList, and empCertificationList). Can I sort it also by the fields inside the list of ...
JMRAF's user avatar
  • 31
1 vote
1 answer
1k views

How to sort a custom list of Notes and Attachments by LastModifiedDate

In my VF Page I have been asked to show a list of all the Notes and Attachments in one table, and sorted by the common LastModifiedDate ... So I have a wrapper class in my custom controller: public ...
Our Man in Bananas's user avatar
0 votes
3 answers
1k views

Comparing Two Lists of Different Objects

I have two lists for two different objects. They are both are related to opportunities. I want to check to see if the two lists are associated with the same opportunity and, if they are associated ...
Reed's user avatar
  • 13
0 votes
1 answer
222 views

Invalid Type for Comparable Implementation

I am sure this is a simple fix but I can not figure out why my test class can not see my comparable class. The error I am getting is invalid type: CaseInfo. Why would this be happening? I am following ...
Olivia's user avatar
  • 3,461
0 votes
2 answers
2k views

Comparing fields in two different objects in a SOQL query

I am trying to create an Apex Controller that outputs a list of event records. I would only like to print the oldest from each account where the Event is a meeting. After much thought I think the best ...
neo2049's user avatar
  • 390
0 votes
1 answer
152 views

Testclass for wrapper class implements Comparable and contentdocumentlink

I don't know how can I test my contentdocumentlink, in the log I got the information EXCEPTION_THROWN [18]|System.QueryException: Implementation restriction: ContentDocumentLink requires a filter by ...
peXeq's user avatar
  • 471
0 votes
2 answers
2k views

Is there a way in process builder to check if a date is set and if so, if it is greater than something?

I am trying to implement some form of attribution, where there are two cases: Date has not been set (i.e. this is the first opportunity) Date has been set (i.e. this is not the first opportunity) ...
Fabian Bosler's user avatar
0 votes
1 answer
58 views

How can we sort based on the number of matched filtered

Can someone help us with regards to sort based on the number of matched filtered. We need to prioritized the number of matched filtered on SKILLS rather than (skills + training / skills + ...
lone's user avatar
  • 75
0 votes
1 answer
144 views

how to find the period between two periods date?

I have one date "TRIG_DATE" date variable. I want to check where it falls under period1 or period2 In period 1 i have two fields "UperDate1__c" and "LowerDate1__c" In period 2 i have two ...
uma451's user avatar
  • 809
0 votes
1 answer
226 views

How compare wrapper values with a map?

I have a callout that return a response on JSON with "CdOrder" and I have Order__c field on User object. I need to compare the CdOrder that is on a Wrapper with a Map that has the key with ...
Alexia's user avatar
  • 83
0 votes
1 answer
78 views

Sorting of the 2 child records referencing each of their date fields (START DATE)

I have three objects, the Professional_Experience__c, Assignment__c, and Project__c. Professional Experience has two child (Assignment__c, and Project__c). Then the Assignment__c has also a child (...
JMRAF's user avatar
  • 31
0 votes
2 answers
298 views

Comparable Interface not sorting

I am trying to implement the comparable interface but I cannot get it to work, nothing seems to make any difference with the ordering of the lists. public Class MyWrapper implements Comparable { ...
realtek's user avatar
  • 163
-2 votes
1 answer
122 views

Sort List by multiple criteria

I have a requirement that I need to sort a list of records by multiple criteria but only proceed to the following sorting criteria if there're still duplicates: Example: First sort by Type and if ...
molinet's user avatar
  • 925
-3 votes
1 answer
285 views

Get most recent dates from a AggregateResult list by comparing

I am running the below code List<AggregateResult> lstWO = [select Id, AccountId, MAX(Completed_Date__c) CompletedDate from WorkOrder WHERE Order__c IN (Select Id from Order WHERE AccountId = '...
sfdc_to_learn's user avatar