Custom Sort Wrapper Class - Salesforce Developer Community

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

I created a wrapper class that implements the Comparable interface. However, when I sort the list of wrapper, the list is still sorting by ... LoginwithSalesforce Don'thaveanaccount? SignupforaDeveloperEdition BrowsebyTopic ApexCodeDevelopment(86622) GeneralDevelopment(53776) VisualforceDevelopment(36733) APIsandIntegration(15806) Lightning(15647) Trailhead(11258) Formulas&ValidationRulesDiscussion(10640) OtherSalesforceApplications(7731) JobsBoard(6626) Force.comSites&Site.com(4714) Mobile(2608) JavaDevelopment(3888) .NETDevelopment(3500) Security(3170) Mobile(2608) VisualWorkflow(2338) AppExchangeDirectory&Packaging(2325) Perl,PHP,Python&RubyDevelopment(2012) ChatterandChatterAPIDevelopment(1702) SalesforceLabs&OpenSourceProjects(1215) DesktopIntegration(1140) Architecture(926) SchemaDevelopment(912) Apple,MacandOSX(791) VBandOfficeDevelopment(633) EinsteinPlatform(188) Salesforce$1MillionHackathon(180) SalesforceSummerofHacks(173) ViewMoreTopics SeeAllPosts Ask Search: ResetSearch WelcometoSupport! SearchforanansweroraskaquestionofthezoneorCustomerSupport. Needhelp? Dismiss Youneedtosignintodothat Signintostartsearchingquestions Don'thaveanaccount? SignupforaDeveloperEdition ShowAllQuestionssortedbyDatePosted ShowAllQuestionsUnansweredQuestionsUnsolvedQuestionsSolvedQuestions sortedbyDatePostedRecentActivityMostPopular +StartaDiscussion Youneedtosignintodothat Signintostartadiscussion Don'thaveanaccount? SignupforaDeveloperEdition UnsolvedQuestionsThisQuestion FlintLockwood CustomSortWrapperClassIcreatedawrapperclassthatimplementstheComparableinterface.However,whenIsortthelistofwrapper,thelistisstillsortingbythename  publicwithsharingclassSampleSortimplementsComparable{ privateGoal__cgoalRecord; publicCaseSLAWrapperClass(Goals__cs){ goalRecord=s; } publicIntegercompareTo(ObjectcompareTo) { SampleSortcompareToGoal=(SampleSort)compareTo; if(goalRecord.Display_Order__ccompareToGoal.goalRecord.Display_Order__c) return1; elseif(goalRecord.Display_Order__cStudList{get;set;} publicSample(){ StudList=newList(); Students1=newStudent('Ganesh',12); StudList.add(s1); Students2=newStudent('Arun',82); StudList.add(s2); Students3=newStudent('Vignesh',32); StudList.add(s3); Students4=newStudent('Younis',55); StudList.add(s4); Students5=newStudent('Azhar',42); StudList.add(s3); StudList.sort(); } //wrapperclassforComparableInterface globalclassStudentimplementsComparable{ globalStringStudentName{get;set;} globalIntegerStudentAge{get;set;} globalStudent(StringName,IntegerAge){ StudentName=Name; StudentAge=Age; } globalIntegercompareTo(ObjectObjToCompare){ returnStudentName.CompareTo(((Student)ObjToCompare).StudentName); } } } Page

Checkbelowpostformoreinformation1)https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_comparable.htm February20,2017·Like0·Dislike0 Youneedtosignintodothat. Needanaccount? SignUp Haveanaccount? SignIn Dismiss Needhelp? × Selectacategory



請為這篇文章評分?