Implemented comparable and comparator interfaces, added methods code.