# Python | Convert list of string into sorted list of integer

Given a list of string, write a Python program to convert it into sorted list of integer.

Examples:

```Input: ['21', '1', '131', '12', '15']
Output: [1, 12, 15, 21, 131]

Input: ['11', '1', '58', '15', '0']
Output: [0, 1, 11, 15, 58]
```

Let’s discuss different methods we can achieve this task.

Method #1: Using `map `and `sorted()`

 `# Python code to convert list of ` `# string into sorted list of integer ` ` `  `# List initialization ` `list_string ``=` `[``'21'``, ``'1'``, ``'131'``, ``'12'``, ``'15'``] ` ` `  `# mapping ` `list_map ``=` `map``(``int``, list_string) ` ` `  `# sorting list ` `list_sorted ``=` `sorted``(list_map) ` ` `  `# Printing sorted list of integers ` `print``(list_sorted) `

Output:

```[1, 12, 15, 21, 131]
```

Method #2: Using list comprehension

 `# Python code to convert list of  ` `# string into sorted list of integer ` ` `  `# List initialization ` `list_string ``=` `[``'11'``, ``'1'``, ``'58'``, ``'15'``, ``'0'``] ` ` `  `# Using list comprehension ` `output ``=` `[``int``(x) ``for` `x ``in` `list_string] ` ` `  `# using sort function ` `output.sort() ` ` `  `# Printing output ` `print``(output) `

Output:

```[0, 1, 11, 15, 58]
```

Method #3: Using iteration

 `# Python code to convert list of ` `# string into sorted list of integer ` ` `  `# List initialization ` `list_string ``=` `[``'11'``, ``'1'``, ``'58'``, ``'15'``, ``'0'``] ` ` `  `# using iteration and sorted() ` `list_sorted ``=` `sorted``(``int``(x) ``for` `x ``in` `list_string) ` ` `  `# printing output ` `print``(list_sorted) `

Output:

```[0, 1, 11, 15, 58]
```

My Personal Notes arrow_drop_up

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.