The program given below using the “while”
loop.
Output is
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_ZopQsw_VTnKu7j7cc47RYW7M-6T-Mtn2H5IBKC2o3UDVyvgO_DUBqo7IvvjiOPTOVWDN04G3OPcvbjGyJyBs_E6kL9BFyFLsdJe5TEBe-LLEmMnZk-7OkmI9xCx1an11DDup5kURb6o/s1600/7.png)
The Bubble Sort – Interactive Version
Python,
however, has its own sorting mechanisms. No one needs to write their own sorts,
as there is a sufficient number of ready-to-use tools.
See the below examples.
Example -1
Output is
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTeCmyyhNzC4E38GlvkiL5ER0RQasg36R3n0Jkw8lPvVU-aeAJTS7uilZzcxnstRkxGm5dqEW-ra2ioFnwMQ9Z2Ci1Qcpzgb_7xernkTt8LdH4p-MH6N-Es0yku1ntGhgcojsXD7WzeIs/s1600/9.png)
All the lists have a method named “sort ()” which sorts them as fast as possible.
Example -2
Output is
reverse () Method
Example -1
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr-56hJSorCe3RWAYd40TPw3FKblucOEmA31J7maUWLjYJPjKW6I-SJtlAKJV_XDnSRWCqCCElKmoIOcdwdwDS6U_dG7ufHX_1f46xJUKmjrcvxQlx6p4VhahZ8Dnd_xub9H-Vdcn4Cxk/s1600/12.png)
Output is
Example -2
Output is
No comments:
Post a Comment