Note that there are some explanatory texts on larger screens.

plurals
  1. POPython,Sorting a dictionary
    primarykey
    data
    text
    <p>I am working on a dict in python. I am trying to sort it out alphabetically and split it to look slightly better. Here is the code I have so far in the dictonatary.</p> <pre><code>authorentry = {'author': name, 'date': datef , 'path': path_change , 'msg' : xmlMsgf } if not name in author: author[ name ] = [] author[ name ].append( authorentry ) if not authorentry in author.items(): author['author'] = [authorentry] print sorted (author.keys()), sorted (author.values()) </code></pre> <p>Now what i want it to do is print out the dict in a sorted order based on the author and the date. and also to split it and modified it so it doesn't have all those commas and 'u's if that is possible. Any ideas on how to accomplish it?</p> <p>this is what it looks like when i print it it as it is.</p> <p>how i want is author shows up first in the list not date. And I would like it alphabetical if possible and to remove the commas in the entrys to print it out cleaner. is it possible? </p> <pre><code>[[{'date': ['06-08-2012 09:01:52 PM'], 'path': [u'/branches/Patch_4_2_0_Branch'], 'msg': ['none', u'PATCH_BRANCH:N/A\nBUG_NUMBER:N/A\nFEATURE_AFFECTED:N/A\nOVERVIEW:N/A\nAdding the SVN log size requirement to the branch \n'], 'author': u'glv'}], [{'date': ['06-08-2012 09:01:52 PM'], 'path': [u'/branches/Patch_4_2_0_Branch'], 'msg': ['none', u'PATCH_BRANCH:N/A\nBUG_NUMBER:N/A\nFEATURE_AFFECTED:N/A\nOVERVIEW:N/A\nAdding the SVN log size requirement to the branch \n'], 'author': u'glv'}]] </code></pre> <p>Update: as of right now I can group the authors together but for some reason not only can't i get it alphebetized I cannot even get the author to be the first person on the list what shows up is something similar to this:</p> <pre><code> Date: 06-08-2012 08:56:09 PM Changes by : glv Comments: PATCH_BRANCH:N/A BUG_NUMBER:N/A FEATURE_AFFECTED:N/A OVERVIEW:N/A Adding the svn commit line requrement Directory Location: /trunk </code></pre> <p>The way i wanted it ordered is more like this. </p> <pre><code> Changes by : glv Date: 06-08-2012 08:56:09 PM Directory Location: /trunk Comments: PATCH_BRANCH:N/A BUG_NUMBER:N/A FEATURE_AFFECTED:N/A OVERVIEW:N/A Adding the svn commit line requrement </code></pre> <p>I tried the OrderedList to see if I can get it to work that way but so far no luck or success. Is there something I am missing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload