Changeset db08737 in sasview for theoryview/perspectives/theory


Ignore:
Timestamp:
Sep 23, 2010 2:40:48 PM (14 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
20905a0
Parents:
a1b2471
Message:

custom order for multishell parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • theoryview/perspectives/theory/model_panel.py

    re99126a rdb08737  
    528528        self.disp_list=self.model.getDispParamList() 
    529529        
    530         keys.sort() 
     530        def custom_compare(a,b): 
     531            """ 
     532            Custom compare to order, first by alphabets then second by number. 
     533            """  
     534            a_last = a[len(a)-1] 
     535            b_last = b[len(b)-1] 
     536             
     537            num_a = None 
     538            num_b = None 
     539            # check if it contains a int number(<10) 
     540            try:  
     541                num_a = int(a_last) 
     542            except: pass 
     543            try: 
     544                num_b = int(b_last) 
     545            except: pass 
     546            # both have a number     
     547            if num_a != None and num_b != None: 
     548                if num_a > num_b: return 1 
     549                elif num_a == num_b:  
     550                    return cmp(a.lower(), b.lower()) 
     551                else: return -1 
     552            # one of them has a number 
     553            elif num_a == None: return -1 
     554            elif num_b == None: return 1 
     555            # no nuumbers 
     556            else: 
     557                return cmp(a.lower(), b.lower()) 
     558             
     559        keys.sort(custom_compare) 
     560 
    531561     
    532562        iy = 0 
Note: See TracChangeset for help on using the changeset viewer.