def print_sorted_device_list(self, device_list=None, sort_key='<STR_LIT>'):
dev_list = device_list if device_list is not None else self.get_all_devices_in_portal()<EOL>sorted_dev_list = []<EOL>if sort_key == '<STR_LIT>':<EOL><INDENT>sort_keys = [ k[sort_key] for k in dev_list if k[sort_key] is not None ]<EOL>sort_keys = sorted(sort_keys)<EOL>for key in sort_keys:<EOL><INDENT>sorted_dev_list.extend([ d for d in dev_list if d['<STR_LIT>'] == key ])<EOL><DEDENT><DEDENT>elif sort_key == '<STR_LIT:name>':<EOL><INDENT>sort_keys = [ k['<STR_LIT:info>']['<STR_LIT:description>'][sort_key]for k in dev_list if k['<STR_LIT:info>']['<STR_LIT:description>'][sort_key] is not None ]<EOL>sort_keys = sorted(sort_keys)<EOL>for key in sort_keys:<EOL><INDENT>sorted_dev_list.extend( [ d for d in dev_listif d['<STR_LIT:info>']['<STR_LIT:description>'][sort_key] == key<EOL>]<EOL>)<EOL><DEDENT><DEDENT>elif sort_key == '<STR_LIT>':<EOL><INDENT>sort_keys = [ k[sort_key] for k in dev_list if k[sort_key] is not None ]<EOL>sort_keys = sorted(sort_keys)<EOL>for key in sort_keys:<EOL><INDENT>sorted_dev_list.extend([ d for d in dev_list if d[sort_key] == key ])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print("<STR_LIT>".format(sort_key))<EOL>sort_keys = None<EOL><DEDENT>self.print_device_list(device_list=sorted_dev_list)<EOL>
Takes in a sort key and prints the device list according to that sort.

Default sorts on serial number.

Current supported sort options are:
    - name
    - sn
    - portals_aliases

Can take optional device object list.