>>> for values in dict1:
... dict1[values].sort()
...
>>> dict1
{'18': ['1234', '4000'], '12': ['123', '1860', '187', '4821', '7000', '9000']}

Full sorting happens for values of '18'. The values of '12' are partially sorted.
but '18' and '12' are themselves not sorted. I don't know whats happening!

Hey Hi...
i am also new in python and faced same problem. But there is a solution U can use ordereddict package which provide many facility like isert iteam is specific order and sort dictionary.

>>> dict1={'12':['123','187','1860','4821','7000','9000'],'18':['1234','4000']}
>>> L = sorted((int(k), sorted(int(x) for x in v)) for k, v in dict1.items())
>>> print L
[(12, [123, 187, 1860, 4821, 7000, 9000]), (18, [1234, 4000])]
>>> M = [(k, x) for k, v in L for x in v]
>>> M
[(12, 123), (12, 187), (12, 1860), (12, 4821), (12, 7000), (12, 9000), (18, 1234), (18, 4000)]

Yes, you can't sort a dictionary, but you can print it in a sorted format.

2. PRINTING (a sorted dict by key)
d = {'A':3, 'B':4, 'C':2', D':1, }
from operator import itemgetter
dlist = sorted(d.items(), key=itemgetter(0)) # sorted by key
for elt in dlist:
print ("--", elt[0], ":", elt[1])

3. PRINTING (a sorted dict by value)
from operator import itemgetter
dlist = sorted(d.items(), key=itemgetter(1)) # sorted by value
for elt in dlist:
print ("--", elt[0], ":", elt[1])

It's worth mentioning that Python has a number of dictionary implementations that maintain the keys in sorted order for faster iterations. Consider the sortedcontainers module which is pure-Python and fast-as-C implementations. You could use the SortedDict type as a replacement for your own dictionary.

Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...