Linked Questions

175 votes
1 answer
177k views

I have a list of strings containing numbers and I cannot find a good way to sort them. For example I get something like this: something1 something12 something17 something2 something25 something29 ...
Michal's user avatar
  • 6,812
84 votes
3 answers
170k views

I have a directory with jpgs and other files in it, the jpgs all have filenames with numbers in them. Some may have additional strings in the filename. For example. 01.jpg Or it could be Picture 03....
ChumbiChubaGo's user avatar
23 votes
3 answers
23k views

I would like to know if there is something similar to PHP natsort function in Python? l = ['image1.jpg', 'image15.jpg', 'image12.jpg', 'image3.jpg'] l.sort() gives: ['image1.jpg', 'image12.jpg', '...
Silver Light's user avatar
  • 46.3k
4 votes
1 answer
12k views

I have a list of file: foo_00.txt foo_01.txt foo_02.txt foo_03.txt foo_04.txt foo_05.txt foo_06.txt foo_07.txt foo_08.txt foo_09.txt foo_10.txt foo_11.txt ......... ......... foo_100.txt foo_101.txt ...
Gianni Spear's user avatar
  • 8,058
8 votes
2 answers
14k views

How to add files into a list by order In my directory i have the following files: slide1.xml, slide2.xml, slide3.xml ... slide13.xml os.listdir(path) doesn't return me a list by order I've tried ...
Pythonizer's user avatar
  • 1,204
7 votes
1 answer
19k views

I have a number of files in a folder with names following the convention: 0.1.txt, 0.15.txt, 0.2.txt, 0.25.txt, 0.3.txt, ... I need to read them one by one and manipulate the data inside them. ...
Gabriel's user avatar
  • 43k
0 votes
2 answers
12k views

I have a directory containing a lot of textfiles named in a specific order: 0.txt 1.txt 2.txt .... 100.txt 101.txt ..... 40000.txt When im trying to retrieve a sorted list of all the files im using: ...
StevePick's user avatar
5 votes
3 answers
27k views

In attempt to learn python by practicing, I am trying to implement and test out quick sort algorithm using python. The implementation itself was not difficult, however the result of the sort is ...
Ishiro Kusabi's user avatar
5 votes
1 answer
12k views

I have a list that its elements are composed of a letters and numbers as shown below : ['H1', 'H100', 'H10', 'H3', 'H2', 'H6', 'H11', 'H50', 'H5', 'H99', 'H8'] I wanted to sort it, so I used the ...
singrium's user avatar
  • 3,056
3 votes
4 answers
1k views

The contents of my dictionary is like so:- >>> dict {'6279': '45', '15752': '47', '5231': '30', '475': '40'} I tried using the sort function on the keys. I noticed that the sort function ...
leba-lev's user avatar
  • 2,916
4 votes
3 answers
11k views

I have some trouble making a code that arranges a .txt file in numerical order. The problem I'm having is when ordering numbers 77, 45, 85, 100 in the .txt file it orders it as 100, 45, 77, 85; 100 ...
B_lo's user avatar
  • 29
2 votes
4 answers
4k views

I have data rows and wish to have them presented as follows: 1 1a 1a2 2 3 9 9.9 10 10a 11 100 100ab ab aB AB As I am using pyQt and code is contained within a TreeWidgetItem, the code I'm trying to ...
PedroMorgan's user avatar
2 votes
2 answers
6k views

I tried to sort using sorted dir =["A1","A2","A10","A3"] sorted(dir) My expected array is ["A1","A2","A3","A10"] but actual result is ["A1", "A10", "A2", "A3"] How to sort array by name in python ?
saturngod's user avatar
  • 25k
3 votes
2 answers
2k views

I have a python dictionary: d = {'a1': 123, 'a2': 2, 'a10': 333, 'a11': 4456} When I sort the dictionary using OrderedDict I get the following output: from collections import OrderedDict OrderedDict(...
Jeril's user avatar
  • 8,631
1 vote
3 answers
4k views

I need to create a video out of sequence of images in python. I found this code online that works fine but I am having a small problem with the ordering of the images when being read in python. Even ...
Aris's user avatar
  • 31

15 30 50 per page
1
2 3 4 5
17