<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks, Danny.<br>
<br>
You see, I didn't put all the keys and values in the dicionary
manually. It was generated while parsing a file with some Python code,
that's why the dict is not in order. I just want to do it to read
easier and look something up.<br>
<br>
How will I then put my dict together again after sorting the items, so
that the keys will follow from small to large?<br>
<br>
Johan<br>
<br>
Danny Yoo wrote:
<blockquote
 cite="midPine.LNX.4.44.0511040026540.5479-100000@hkn.eecs.berkeley.edu"
 type="cite">
  <pre wrap="">
  </pre>
  <blockquote type="cite">
    <pre wrap="">ser_port = {'4401': 'ds-srvr', \
 '5427': 'sco-peer-tta', \
 '4446': 'n1-fwp', \
 '3734': 'synel-data', \
 '4447': 'n1-rmgmt', \
 '5745': 'fcopy-server', \
 '5990': 'wbem-exp-https', \
 '4026': 'as-debug', \
 '3724': 'battlenet'}
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Hi Johan,

Just as a quick side note: all those continuation characters '\' at the
end of those lines are unneccessary --- Python knows that there's more to
the line because of it's in the middle of a dictionary definition.  So you
can clean things up slightly by doing:

###########################
ser_port = {
 '4401': 'ds-srvr',
 '5427': 'sco-peer-tta',
 '4446': 'n1-fwp',
 '3734': 'synel-data',
 '4447': 'n1-rmgmt',
 '5745': 'fcopy-server',
 '5990': 'wbem-exp-https',
 '4026': 'as-debug',
 '3724': 'battlenet',
}
###########################

Everything lines up nicely, and there's a little less line noise.  *grin*

We can even leave a trailing comma on the last key-value pair, just to
make adding more entries into the list easier, as we've done for the
'3724' entry.


I hope this helps!


  </pre>
</blockquote>
</body>
</html>