Здравейте, дадоха ми следната задача, обаче се мъча вече доста време и нищо не се получава.. Ако може някой да помогне ще съм много благодарен Given the array A of size M
(a) Find the K-th smallest element. Find the K-th largest element.
(b) Calculate the distance between every two consecutive elements.
(c) Output A as a list of components sorted in ascending order. For example:
A = [5, 9, 3, 3, 6,2, 1, 7, 8]
Sorted components = [5, 9,], [3,3,6], [2], [1,7,8]
Ето това е задачата..
Благодаря предварително и се извинявам ако не е в правилния раздел темата 
(a) Find the K-th smallest element. Find the K-th largest element.
(b) Calculate the distance between every two consecutive elements.
(c) Output A as a list of components sorted in ascending order. For example:
A = [5, 9, 3, 3, 6,2, 1, 7, 8]
Sorted components = [5, 9,], [3,3,6], [2], [1,7,8]
Ето това е задачата..