Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python sorting array without inbuilt sort

data_list = [-5, -23, 5, 0, 23, -6, 23, 67]
new_list = []

while data_list:
    minimum = data_list[0]  # arbitrary number in list 
    for x in data_list: 
        if x < minimum:
            minimum = x
    new_list.append(minimum)
    data_list.remove(minimum)    

print new_list
Comment

sorting numbers in python without sort function

number=[1,5,6,9,0]
for i in range(len(number)):
  for j in range(i+1,len(number)):
    if number[i]<number[j]:
      number[i],number[j]=number[j],number[i]
print(number)
Comment

PREVIOUS NEXT
Code Example
Python :: smtplib not sending email 
Python :: python get volume free space 
Python :: how to change the background of heading in tkinter 
Python :: how to print python 
Python :: python list of colors 
Python :: pandas add column with constant value 
Python :: how to use dictionary comprehension to make a dictionary for some names of a list in python 
Python :: convert data type object to string python 
Python :: turn off xticks matplotlib 
Python :: concatenate dataframes 
Python :: how to use regex in a list 
Python :: python replace accented characters code 
Python :: python remove multiple characters from string 
Python :: python calculate derivative of function 
Python :: second y axis matplotlib 
Python :: modify string in column pandas 
Python :: vault python client 
Python :: django permission required 
Python :: playsound python 
Python :: The specified file cannot be played on the specified MCI device. The file may be corrupt, not in the correct format, or no file handler available for this format. python 
Python :: how to find the number of times a number appears in python 
Python :: pipenv with specific python version 
Python :: python convert exponential to int 
Python :: How to copy any text using python 
Python :: create or update django models 
Python :: or operator in django queryset 
Python :: get first row sqlalchemy 
Python :: how to check if a cell is empty in openpyxl 
Python :: get time format python2 hours minutes seconds milliseconds 
Python :: tkinter button position 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =