HELP! Jason can't find his textbook! It is two days before the test date, and Jason's textbooks are all out of order! Help him sort a list (ArrayList in java) full of textbooks by subject, so he can study before the test.

The sorting should **NOT** be case sensitive

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Sorting

Data structures

Starter code: def sorter(textbooks):
	

Solutions:
def sorter(textbooks):
	return sorted(textbooks, key=str.lower)


def sorter(textbooks):
	return sorted(textbooks, key=str.casefold)


def sorter(textbooks):
	return sorted(textbooks, key=lambda arg: arg.lower())


sorter = lambda x: sorted(x, key=lambda s: s.lower())


sorter = lambda text: sorted(text, key=lambda s: s.lower())


def sorter(lst):
	return sorted(lst, key=lambda e: e.lower())


def sorter(textbooks):
	return sorted(textbooks, key=lambda text: text.lower())


def sorter(textbooks):

	def f(e):
		return e.lower()
	sorted = textbooks.sort(key=f)
	return textbooks


def sorter(textbooks):
	d = {t.lower(): t for t in textbooks}
	return [d[t] for t in sorted(d)]


sorter = lambda textbooks: sorted(textbooks, key=str.lower)


from typing import List

def sorter(textbooks: List[str]):
	return sorted(textbooks, key=str.lower)


def sorter(textbooks):
	textbooks.sort(key=lambda x: x.lower())
	return textbooks


def myf(a):
	return a.lower()

def sorter(textbooks):
	return sorted(textbooks, key=myf)


def sorter(textbooks):
	textbooks.sort(key=str.lower)
	return textbooks


def sorter(textbooks):
	listtemp = [(x.lower(), x) for x in textbooks]
	listtemp.sort()
	return [x[1] for x in listtemp]


def sorter(textbooks):
	r = {i.lower(): i for i in textbooks}
	return [r[i] for i in sorted(r)]


def sorter(textbooks):
	subjects = dict(((sub.lower(), sub) for sub in textbooks))
	return [subjects[sub] for sub in sorted(subjects.keys())]


sorter = lambda textbooks: list(sorted(textbooks, key=lambda s: s.lower()))


sorter = lambda textbooks: sorted(textbooks, key=str.casefold)


def sorter(textbooks):
	return list(sorted(textbooks, key=lambda e: e.lower()))


import functools

def cmp(a, b):
	aa = a.lower()
	bb = b.lower()
	if aa > bb:
		return 1
	elif bb > aa:
		return -1
	else:
		return 0

def sorter(textbooks):
	return sorted(textbooks, key=functools.cmp_to_key(cmp))


from typing import List

def sorter(textbooks: List[str]) -> List[str]:
	return sorted(textbooks, key=str.casefold)


def sorter(tks):
	return sorted(tks, key=lambda s: s.lower())


def sorter(textbooks):
	return sorted(textbooks, key=lambda v: (v.casefold(), v))


def get_first(element):
	return element[0]

def sorter(textbooks):
	lst = [(el.lower(), el) for el in textbooks]
	lst1 = sorted(lst, key=get_first)
	return [el[1] for el in lst1]


def sorter(textbooks):
	lst = sorted([(el.lower(), el) for el in textbooks])
	return [el[1] for el in lst]


def sorter(textbooks):

	def f(x):
		return x.lower()
	return sorted(textbooks, key=f)


def sorter(textbooks):
	return sorted(sorted(textbooks, key=lambda x: x[1].lower()), key=lambda x: x[0].lower())


def sorter(textbooks):
	x = sorted(textbooks, key=lambda s: s.casefold())
	return x


def sorter(textbooks):
	result = []
	books_lowcase = [x.lower() for x in textbooks]
	books_dict = dict(zip(books_lowcase, textbooks))
	dict_keys_sort = list(books_dict.keys())
	dict_keys_sort.sort()
	for i in dict_keys_sort:
		result.append(books_dict[i])
	return result


import re

def sorter(textbooks):
	textbooks.sort(key=str.lower)
	return textbooks


def sorter(textbooks):
	s = sorted(textbooks)
	if textbooks == s:
		return textbooks
	if s == s.sort(key=str.lower):
		return s.sort(key=str.lower)
	else:
		return s


def lower_case(predmet):
	return predmet.lower()

def sorter(textbooks):
	return sorted(textbooks, key=lower_case)


def register(textbook):
	return textbook.lower()

def sorter(textbooks):
	textbooks.sort(key=register)
	return textbooks


def sorter(textbooks):
	return sorted(textbooks, key=lambda s: s.lower())


def sorter(*textbooks):
	for textbook in textbooks:
		print(textbook.sort(key=str.lower))
	return textbook


def f(x):
	x = x.lower()
	return x

def sorter(textbooks):
	textbooks.sort(key=f)
	return textbooks


def sorter(textbooks):
	textbooks = sorted(textbooks, key=lambda x: x[0:] if x[0:].islower() else x[0:].lower())
	return textbooks


def sorter(textbooks):
	return sorted([i for i in textbooks], key=lambda str: str.lower())


def sorter(t):
	t.sort(key=str.casefold)
	return t


import locale

def sorter(textbooks):
	textbooks.sort(key=lambda x: x.lower())
	return textbooks


def sorter(t):
	return sorted(t, key=lambda t: t.casefold())


def sorter(textbooks):
	return sorted(textbooks, key=lambda x: x[0:2].lower())


def sorter(textbooks):
	lst_books = []
	for i in textbooks:
		lst_books.append(i)
	return sorted(lst_books, key=str.lower)


def sorter(textbooks):
	textbooks_low = [el.lower() for el in textbooks]
	textbooks_low_sorted = sorted(textbooks_low)
	testbooks_sorted_indexes = [textbooks_low.index(el) for el in textbooks_low_sorted]
	return [textbooks[ind] for ind in testbooks_sorted_indexes]


def sorter(textbooks):
	if textbooks != int:
		return sorted(textbooks, key=str.lower)


def sorter(text_books):
	return sorted(text_books, key=str.lower)


def sorter(textbooks):
	return sorted(textbooks, key=lambda t: (t.lower(), t))


def sorter(textbooks):
	arr = []
	for (i, book) in enumerate(textbooks):
		arr.append([book.lower(), i])
	arr = sorted(arr)
	for (i, book) in enumerate(arr):
		arr[i] = textbooks[book[1]]
	return arr


sorter = lambda books: sorted(books, key=lambda _: _.lower())


import string

def sorter(textbooks):
	return sorted(textbooks, key=str.lower)


sorter = lambda t: sorted(t, key=lambda s: s.lower())


def sorter(textbooks):
	a = sorted(textbooks, key=str.casefold)
	print(textbooks, a)
	return a


def sorter(textbooks):
	obj = {}
	lower_case_textbooks = []
	for textbook in textbooks:
		lower_case_textbook = textbook.lower()
		obj[lower_case_textbook] = textbook
		lower_case_textbooks.append(lower_case_textbook)
	sorted_textbooks = sorted(lower_case_textbooks)
	output_list = []
	for sorted_textbook in sorted_textbooks:
		output_list.append(obj[sorted_textbook])
	return output_list


def sorter(textbooks):
	print(sorted(textbooks))
	return sorted(textbooks, key=lambda x: x.lower())


def sorter(arr):
	for i in range(len(arr) - 1):
		for j in range(len(arr) - i - 1):
			if arr[j].lower() > arr[j + 1].lower():
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
	return arr


def sorter(textbooks):
	return [a[1] for a in sorted([(b.lower(), b) for b in textbooks])]


def sorter(t):
	return sorted(t, key=str.casefold)


def sorter(tb):
	return sorted(tb, key=lambda x: x.lower())


def sorter(textbooks):
	sorted = [book.lower() for book in textbooks]
	sorted.sort()
	final = textbooks.copy()
	for book in textbooks:
		final[sorted.index(book.lower())] = book
	return final


def sorter(textbooks):
	copy = [text.lower() for text in textbooks]
	final = []
	to_sort = list(copy)
	to_sort.sort()
	for t in to_sort:
		final.append(textbooks[copy.index(t)])
	return final


sorter = lambda x: sorted(x, key=str.casefold)


def sorter(textbooks):
	a = [i.lower() for i in textbooks]
	s = sorted(a)
	for i in range(len(s)):
		if s[i] in textbooks:
			pass
		else:
			s[i] = textbooks[a.index(s[i])]
	return s


def sorter(textbooks):
	return sorted(textbooks, key=lambda w: w.casefold())


def sorter(textbooks):
	ret = [t for t in textbooks]
	ret.sort(key=lambda x: x.lower())
	return ret


import numpy as np

def sorter(textbooks):
	return sorted(textbooks, key=str.lower)


import functools

def compares(item1, item2):
	if len(item1) == 0:
		return -1
	if len(item2) == 0:
		return 1
	if ord(item1[0].lower()) < ord(item2[0].lower()):
		return -1
	elif ord(item1[0].lower()) > ord(item2[0].lower()):
		return 1
	else:
		return compares(item1[1:], item2[1:])

def compare(item1, item2):
	return compares(item1, item2)

def sorter(textbooks):
	return sorted(textbooks, key=functools.cmp_to_key(compare))


def sorter(t):
	a = sorted(t, key=str.lower)
	return a


class Book:

	def __init__(self, subject):
		self.subject = subject

	def __lt__(self, other):
		return self.subject.lower() < other.subject.lower()

def sorter(textbooks):
	a = [Book(subj) for subj in textbooks]
	a.sort()
	output = [i.subject for i in a]
	return output


def sorter(textbooks):
	return sorted(textbooks, key=lambda v: v.lower())


def sorter(textbooks):
	sortbooks = sorted([x.lower() for x in textbooks])
	out = []
	for sb in sortbooks:
		for tb in textbooks:
			if sb == tb.lower():
				out.append(tb)
	return out


def sorter(textbooks):
	index = {word.lower(): word for word in textbooks}
	keys = sorted(index.keys())
	return [index[key] for key in keys]


def sorter(textbooks):
	return sorted([textbook for textbook in textbooks], key=lambda x: x.lower())


sorter = lambda textbooks: sorted(textbooks, key=lambda t: t.lower())