how can I make this code without built in function sort sorted

0 votes
class KeyIndex:

    def __init__(self, a):

        self.k = a

    def search(self, val):

        for ele in self.k:

            if ele == val:

                return True

        else:

            return False

    def sort(self):

        return sorted(self.k)

if __name__ == '__main__':

    a = [51,32,9,14,17,4]

    i = KeyIndex(a)

    if i.search(5):

        print(True)

    else:

        print(False)

    if i.search(10):

        print(True)

    else:

        print(False)

    print(i.sort())
May 11, 2021 in Python by anonymous

edited Mar 4 7 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP