I am trying to order a list containing integers. I want them sorted in numerical order from lowest to highest. I tried using sort but got the list baxk exactly as it was.

x = [5, 3, 7]
x.sort
print x

What command would I usr to make this return [3, 5, 7]?
Thanks for your help.

you almost had it:

x = [5, 3, 7]
x = x.sort() # or x.sorted()
print x

Thanks for the help scru. That's what I was missing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.