Nov-23-2019, 08:52 PM
hi all,
I have a class which has a method which sort data in it. I need to create another method to check if data object I am dealing with is sorted or not. When I declare data object first it's not sorted. For checking whether this is sorted or not what I am doing is:
1) Create another data object and assigning original data object in it
2) Now sorting this new data object
3) Comparing newly created and sorted data object with original one
Problem I have is it's showing sorted as when I create a new data object and assign value of existing one in it and then sort this one, it' sorting original one also
I have a class which has a method which sort data in it. I need to create another method to check if data object I am dealing with is sorted or not. When I declare data object first it's not sorted. For checking whether this is sorted or not what I am doing is:
1) Create another data object and assigning original data object in it
2) Now sorting this new data object
3) Comparing newly created and sorted data object with original one
Problem I have is it's showing sorted as when I create a new data object and assign value of existing one in it and then sort this one, it' sorting original one also
def isOrdered(self): sortedDeck=self.deck sortedDeck.sort() for i in range(0, len(self.deck)): print(self.deck[i],sortedDeck[i])Any idea why it would be happening?