This python module will help you to sort any numbers within a list, either integer or double type, or a mix of both.

For example, if you enter this list, [3.4, -4, 3.5, 7, 14] and pass in True as the second parameter to the below function.

import intesort as sortx

print(sortx.intesort([3.4, -4, 3.5, 7, 14], True))

You will get [-4, 3.4, 3.5, 7, 14] in return where this function will sort the number list in the ascending order. If you pass in False then the outcome will be [14, 7, 3.5, 3.4, -4] instead. If you do not pass in the second parameter then the function will assume you want an ascending order list. If you do not pass in anything to the above function, then this function will return [].

You can download this module on PyPI through below command on your command prompt. Enjoy!

pip install intesort

An example of how to use this module. Suppose you are given a list of numbers and you wish to turn them into an ascending list and then print stars on the scene based on those numbers. You can use the above module to help you reorganize the unsorted number list in the ascending order before printing the star on the scene.

import intesort as sortx

li = [12, 4, 23, 3, 9]

star = sortx.intesort(li)

for num in star:
    str = ''
    for i in range(0, num):
        str += '*'

The above program will produce the below outcome.


The numbers are sorted before the stars get printed on the screen!

Please follow and like us:

1 Comment

  1. Who is the audience for this blog? Are you seeking feedback on your coding exercises, or are you trying to illustrate proper Python coding? I hope it’s not the latter; I’m going to assume the former and offer some thoughts:

    (1) There’s no need to import any sorting function. sort() is a builtin method of a list, and sorted() is a global builtin.
    (2) Repeated addition on strings is an anti-pattern that should be avoided. Alas, I’ve seen that with other of your examples.

    Essentially, what you’ve done in eleven lines should take no more than three:
    li = [12, 4, 23, 3, 9]
    for num in sorted(li):
    print(‘*’ * num) # hopefully the indentation won’t be stripped…

    Anyway, I’m hopeful you’re indeed seeking feedback and that this was useful.

Leave a Reply

Your email address will not be published. Required fields are marked *