Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to sort a dictionary in python without sort function

markdict={"Tom":67, "Tina": 54, "Akbar": 87, "Kane": 43, "Divya":73}
l=len(marklist)
  for i in range(l-1):
    for j in range(i+1,l):
      if marklist[i][1]>marklist[j][1]:
            t=marklist[i]
            marklist[i]=marklist[j]
            marklist[j]=t
    sortdict=dict(marklist)print(sortdict)
Comment

PREVIOUS NEXT
Code Example
Python :: python set console title 
Python :: python combine if statements 
Python :: select specific columns in sqlalchemy 
Python :: np.random.choice replace 
Python :: python array sum 
Python :: print hello world 
Python :: dice rolling simulator python code 
Python :: python includes 
Python :: python function to multiply two numbers 
Python :: how to make an error message in python 
Python :: check how many letters in a string python 
Python :: round to 3 significant figures python 
Python :: fizz buzz fizzbuzz python game 
Python :: python serial port 
Python :: youtube bot python 
Python :: python official documentation 
Python :: plt title color 
Python :: sklearn.metrics accuracy_score 
Python :: df read csv 
Python :: flatten lists python 
Python :: set empty dictionary key python 
Python :: adding an item to list in python 
Python :: how to get a user input in python 
Python :: how to find gcd of two numbers in python 
Python :: python if syntax 
Python :: iterating over lines in a file 
Python :: read list of dictionaries from file python 
Python :: calculate sum in 2d list python 
Python :: fastest sorting algorithm java 
Python :: python printing 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =