Python Forum
Python sorts all arrays instead of one.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python sorts all arrays instead of one.
#1
Hello. I want only to sort c1. Using that code it sorts both c and c1
def f(v):
    x=v[0]
    y=v[1]
    return x**2 + x*y + y**2 - 6*x - 9*y
v1 = [0, 0]
v2 = [1, 0]
v3 = [0, 1]
v=[v1,v2,v3]
c=[f(v1),f(v2),f(v3)]
c1=c
c1.sort()
print(*c)
print(*c1)
How to get sorted only c1?
Reply


Messages In This Thread
Python sorts all arrays instead of one. - by Alex009988 - Sep-02-2019, 01:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  2 Different Sorts in a Dataframe stylingpat 1 1,933 Apr-14-2021, 03:02 PM
Last Post: stylingpat
  Writing a lambda function that sorts dictionary GJG 1 2,035 Mar-09-2021, 06:44 PM
Last Post: buran
  Arrays in MATLAB and PYTHON cokhuatlanyeuthuongconhetmuc 2 2,211 Jul-24-2020, 10:47 AM
Last Post: cokhuatlanyeuthuongconhetmuc
  No arrays in Python? twilkinson 2 1,809 Jan-29-2020, 04:42 PM
Last Post: ThiefOfTime

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020