The code is this: def list2dict(label): new_dic = {} final_dic = {} label.sort() print 'label = ' print label print ' ' for (i,k) in enumerate(label): new_dic[i] = k print 'new_dic = ' print new_dic print ' ' # for i in range(len(new_dic)): # print new_dic.get(i) return new_dic and the outputs are bellow: In python everything is always ordered: C:\Python254>python commitment.py label = [[(0, False, False)], [(1, False, False)], [(2, False, False)], [(3, False, Fals e)], [(4, True, True)], [(5, False, False)]] new_dic = {0: [(0, False, False)], 1: [(1, False, False)], 2: [(2, False, False)], 3: [(3, False, False)], 4: [(4, True, True)], 5: [(5, False, False)]} And in Jython: C:\jython2.5.2rc2>jython commitment.py label = [[(0, False, False)], [(1, False, False)], [(2, False, False)], [(3, False, Fals e)], [(4, True, True)], [(5, False, False)]] new_dic = {5: [(5, False, False)], 0: [(0, False, False)], 3: [(3, False, False)], 2: [(2, False, False)], 1: [(1, False, False)], 4: [(4, True, True)]}