code: def getElementByOrder(self, beamline, type, irange):
          
          try:
              assert beamline.upper() in self.kws_bl
          except AssertionError:
              print('%s is not a defined beamline.' % beamline)
              return ''
  
          try:
              orderedLattice_list = self.orderLattice(beamline)
              allmatchedlist = [val for idx, val in enumerate(orderedLattice_list) if val[1] == type.upper()]
              if ',' in str(irange):
                  retlist = [allmatchedlist[int(num)] for num in str(irange).split(',')]
              elif ':' in str(irange):
                  idxlist = map(int, irange.split(':'))
                  if len(idxlist) == 2:
                      idxlist.append(1)
                  idx_start, idx_stop, idx_step = idxlist[0], idxlist[1], idxlist[2]
                  retlist = allmatchedlist[slice(idx_start, idx_stop, idx_step)]
              elif str(irange) == 'all':
                  retlist = allmatchedlist[:]
              else:
                  retlist = [allmatchedlist[int(irange)]]
              return retlist
          except:
              # print('Can not find %s in %s.' % (type, beamline))
              return ''
docs: return element list by appearance order in beamline,
              which could be returned by orderLattice(beamline)
  
              :param beamline: beamline name
              :param type: element type name
              :param irange: selected element range
  
          possible irange definitions:
              irange = 0,      first one 'type' element;
              irange = -1,     last one
              irange = 0,2,3,  the first, third and fourth 'type' element
              irange = 2:10:1, start:end:setp range
              irange = 'all',    all