How to sort list of dates in apex and return the entire record?

文章推薦指數: 80 %
投票人數:10人

This is what I have tried so far and got confused as to how to return all the records after sorting the dates. //Sorting logic List ... AskQuestion ProgrammingTags All community setup lightning lightning-web-components comminity salesforcedx salesforcedx-cli flexipages apex trigger unit-test css slds visual-workflow guest-user debug-logs lookup-filter dependent-lookup marketing-cloud api Howtosortlistofdatesinapexandreturntheentirerecord? Thisquestionalreadyhasananswerhere: SortingaListofdifferentobjectListsbydatetime (1answer) Closed5monthsago. IhaveacustomobjectcalledInsurancewhichhasaStartDatefield.IamplanningtousebubblesorttosorttherecordsbasedontheStartDate.ThisiswhatIhavetriedsofarandgotconfusedastohowtoreturnalltherecordsaftersortingthedates. //Sortinglogic ListlistOfRecords=newList(); integeriterationSize=listOfRecords.size(); for(Insurance__ciList1:insuranceList){ listOfRecords.add(iList1); } for(integery=0;ycompareToins.insuranceDate){ //Setreturnvaluetoapositivevalue. returnValue=1; }elseif(insuranceDatethatValue)return1; elsereturn0; } } publicstaticListsort(Listrecords){ //Wrap Listwrappers=newList(); for(Insurance__crecord:records)wrappers.add(newWrapper(record)); //Usetheplatform'sbuiltinsortalgorithm wrappers.sort(); //Unwrap Listresults=newList(); for(Wrapperwrapper:wrappers)results.add(wrapper.record); returnresults; } } RelatedQuestions Conga-Templatebuilder.OpportunityDatasetnotgettingdisplayed 0 salesforce February24,2022 SFDX:Entitiesnotsupportedonpackageversioncreation 1 salesforcedx February10,2022 LimitationofLightningDataService 2 api February10,2022 HandlingmultipleregexmatchesinAmpscript 1 marketing-cloud February10,2022 ExecutionofBeforeInsertcausedby:System.NullPointerException:Attempttode-referenceanullobjectClass.Battle 1 apex February10,2022 EmailTemplate-Thetemplatedoesnothaveacontrollerthatcanbeselectedforpreview 1 visualforce February10,2022 Byusingoursite,youacknowledgethatyouhavereadandunderstandourPrivacyPolicy&CookiePolicyandTermsandConditions Iagree × Oops!Somethingwentwrong:(Tryagain... OK ×



請為這篇文章評分?