# Create a Program to Implement Sorting in Python Assignment Solution.

## Instructions

Objective
Write a python assignment program to implement sorting.

## Requirements and Specifications

```#!/usr/bin/env python # coding: utf-8 # In[2]:```
```# In[3]: class ListNode: def __init__(self, data, next=None): self.val = data self.next = next def make_list(elements): # create a linked list from the input list head = ListNode(elements[0]) for element in elements[1:]: ptr = head while ptr.next: ptr = ptr.next ptr.next = ListNode(element) return head def print_list(head): # print the values in the linked list ptr = head print('[', end="") while ptr: print(ptr.val, end=", ") ptr = ptr.next print(']') class Solution: def solve(self, node): values = [] head = node # extract the values from the linked list into a list while node: values.append(node.val) node = node.next # implement bubble sort on the list for i in range(len(values) - 1): swapped = False for j in range(len(values) - i - 1): if values[j] > values[j + 1]: values[j], values[j + 1] = values[j + 1], values[j] swapped = True if not swapped: break node = head # put the sorted values back into the linked list for val in values: node.val = val node = node.next return head ob = Solution() head = make_list(data) print_list(ob.solve(head))```