Sort 2D list in Jython/Python -
I am using WLST (Python / Jethan) to get the configuration of some weblogic resources. I loop in a JM module queue and I recovered the name and some other parameters for each queue.
With this information, I create a 2D list, which I want to order with queue.
When I can successfully do it in two ways in the Python console:
operator import items from Lester L = [["queueName1", 1, 2], [ "QueueName2", 2, 3], ["QAname 3", 4, 1]] Sorted (L, Key = Medetter (0))
or
(L,>Python / jethan version in my WL server (version 10.3.5) (I do not really know what it is using ) I do not like it when I use a .py script:
list2d.sort (key = lambda x: x [0])
I get the error:
Problem in starting WLST - traceback (at the end): file "/home/user/scripts/pythonscripts/get_jms_config.py", in line 98, in?
If I try to use the item, then it is not better, as I get the following error:
WLST - Traceback (most Finally, the problem of getting started: file "/ home / penalty / script / Pythonscripts / gate_zms_config.py", in line 5,? ImportError: name can not import itemgetter
Do anyone have any suggestions?
Edit:
def getQueueInformation (): try: list2d = [] j = 1 jms system resource = cmo.getJMSSystemResources (); In JmsSystemResources for JmsSystemResource: queues = jmsSystemResource.getJMSResource (). GetQueues (); To queue in queue: # Print some information line [] row.appand (queue.getName ()) line .append (str (queue.getDeliveryParamsOverrides). GetRedeliveryDelay ())) row.append (str (queue.getDeliveryFailureParams) ) .getRedeliveryLimit ()) list2d.append (line) j + = 1 return list except 2d WLSTException: print 'an error occurred ...',
Regards, Deborah
It seems that you are running Python version 2.4 before, when that was introduced. You can try to use your version:
list2d.sort (lambda left, right: CMP (left [0], right [0]))
Comments
Post a Comment