Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Epic
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#python 2.7.12 print "Hello, world!" list = [3, 1, 16, 14, 18, 5] # we keep sorting until we reach the end of the list for i in xrange(len(list)): minimum = i # find a number stored smaller than the minimum for j in xrange(i + 1, len(list)): # if we find a smaller one, store that to the minimum if(list[j] < list[minimum]): minimum = j #swap the new one we found with the number at the front temp = list[i] list[i] = list[minimum] list[minimum] = temp """selection sort""" import random list = [] for k in xrange(0,10): num = random.randint(1,100) list.append(num) print(list) print(" ")
[
+
]
Show input
Absolute running time: 0.47 sec, cpu time: 0.38 sec, memory peak: 5 Mb, absolute service time: 0,48 sec
edit mode
|
history
|
discussion