A fast and reliable Java micro-library which chooses the sorting algorithm that best fits your needs and sorts the parameter.

Overview

OptimizedSort

A fast and reliable Java micro-library which chooses the sorting algorithm that best fits your needs and sorts the parameter.

About The Project

While I was studying for my Algorithms course I started implementing a Java library which allows you to sort an array of items in the best way.

I implemented it thinking about different necessities and it went out that the time complexity is not everything. Sometimes you could have different necessities like stable or in-place sortings. This library chooses the algorithm that best fits your necessities.

(back to top)

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

  • Download the latest JAR release here or pack the sources by yourself.

Installation

Add the JAR library to the dependencies of your your project.

(back to top)

Usage

First, create a class which implements Comparable:

public class Player implements Comparable<Player> {
  String name;
  int points;

  public Player(String name, int points) {
    this.name = name;
    this.points = points;
  }

  @Override
  public int compareTo(Player o) {
    return this.points - o.points;
  }

  @Override
  public String toString() {
    return this.name;
  }
}

Then, if you want to sort your array of object:

sort = new Sort<>(players); // Sort the array players = sort.sort(); // Print out the results for (Player p : players) { System.out.println(p); }">
Player []players = new Player[]{
                new Player("Simone", 100),
                new Player("John", 20),
                new Player("Joe", 1),
                new Player("Robert", 7),
                new Player("Aldo", 2),
        };

        Sort<Player> sort = new Sort<>(players);

        // Sort the array
        players = sort.sort();

        // Print out the results
        for (Player p : players) {
            System.out.println(p);
        }

You can also configure the algorithm by yourself...

// Use Selection Sort
sort.setAlgorithm("selection");
// Use Heap Sort
sort.setAlgorithm("heap");
// Use Insertion Sort
sort.setAlgorithm("insertion");
// Use Merge Sort
sort.setAlgorithm("merge");
// Use Quick Sort
sort.setAlgorithm("quick");
// Use Shell Sort
sort.setAlgorithm("shell");

... or you can let the library choose the best one using the parameters...

// InPlace: TRUE
// Stable: TRUE
Sort<Player> sort = new Sort<>(players, true, true);

... and you can use a custom comparator too

public class CompareByName implements Comparator<Player> {
    @Override
    public int compare(Player o1, Player o2) {
        return o1.name.compareTo(o2.name);
    }
}
sort.setComparator(new CompareByName());
players = sort.sort();

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Simone Nicol - @en0mia

Project Link: https://github.com/en0mia/OptimizedSort

(back to top)

You might also like...

🦄 Best beautiful java blog, worth a try

🦄 Best beautiful java blog, worth a try

Tale Blog Tale's English meaning for the Story, I believe that every person who insists on writing a blog is a story; Chinese you call it Collapse doe

Dec 30, 2022

Observing a sequence of objects that can be numerically ranked best and worst.

Optimal-Stopping The Secretary Problem from Optimal Stopping. https://en.wikipedia.org/wiki/Optimal_stopping Observing a sequence of objects that can

Feb 3, 2022

Get Best Resources on every Domain here!

Get Best Resources on every Domain here!

Useful Resources for Developers To join DEVs Dungeon GitHub Organization, click here ➤ If you find this REPOSITORY helpful, then do give it a 🌟 by pr

Dec 29, 2022

Spring Boot REST API authentication best practices using JWT

 Spring Boot REST API authentication best practices using JWT

Spring Boot REST API authentication best practices using JWT Token based API authentication with Spring Security and JWT (JSON web Token) Overview Thi

Dec 22, 2022

Best practice of monolithic spring application starter

Best practice of monolithic spring application starter

Best practice of monolithic spring application starter

Jul 19, 2022

Search API with spelling correction using ngram-index algorithm: implementation using Java Spring-boot and MySQL ngram full text search index

Search API with spelling correction using ngram-index algorithm: implementation using Java Spring-boot and MySQL ngram full text search index

Search API to handle Spelling-Corrections Based on N-gram index algorithm: using MySQL Ngram Full-Text Parser Sample Screen-Recording Screen.Recording

Dec 4, 2021

Hashids algorithm v1.0.0 implementation in Java

Hashids.java A small Java class to generate YouTube-like hashes from one or many numbers. Ported from javascript hashids.js by Ivan Akimov What is it?

Dec 29, 2022

A tool which enhances your pojo, powered by java-agent.

A tool which enhances your pojo, powered by java-agent.

Oct 8, 2022

Set of project to test how fast is compilation on your computer

Бенчмарк сборки Android проектов Репозиторий содержит несколько проектов, для которые необходимо запустить тесты и зарепортить их результаты Методика

Jul 29, 2022
Releases(v1.0.1)
Owner
Simone Nicol
Technology and innovation lover. 🤓 Computer Engineering Student @ Politecnico di Torino. 🎓 Backend Developer👨🏻‍💻.
Simone Nicol
This is the repo for ArrayV's Extra Sorts Pack

ArrayV Extra Sorts Pack This is the repo for ArrayV's Extra Sorts Pack. This repo houses many community-made sorts. It has a built-in link to ArrayV,

Josiah (Gaming32) Glosson 4 Jan 31, 2022
Fast, Reliable & Simple Practice Core

Twilight An open-sourced simple Practice Plugin made for the Spigot API (Unfinished) Contact You can contact me on discord via my tag or server: My di

Luca 7 Sep 19, 2022
A suite of software tools and services created to support activity planning and sequencing needs of missions with modeling, simulation, scheduling and validation capabilities

Aerie A suite of software tools and services created to support activity planning and sequencing needs of missions with modeling, simulation, scheduli

NASA Advanced Multi-Mission Operations System 31 Jan 3, 2023
Idk. Simple argument parser for u. Probably needs some changes xd

SimpleArgumentParser Maven <repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories> <de

なるみ 6 Sep 30, 2022
Applied Spring Data JPA technologies including mapping, connecting real DB, Hibernate, Queries, Paging & Sorting, various Relationships, Transactions

University Management In this project, I practiced & applied Spring Data JPA technologies including mapping, connecting real DB, Hibernate, Queries, P

SarvarKhalimov 2 Sep 5, 2022
Simple micro web framework written in Pragmatic Functional Java style

Pragmatica REST Example Example nano web framework written in Pragmatic Functional Java style. Example public class App { public static void main(

Sergiy Yevtushenko 8 Oct 21, 2022
Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.

English | 中文 Apollo - A reliable configuration management system Apollo is a reliable configuration management system. It can centrally manage the con

Apollo 27.6k Jan 5, 2023
The most reliable world manager you've ever seen.

Rift2 - The Opening Electric Boogaloo The most reliable world manager you've ever seen. Contributors & creators: Cyberpwn Vatuu Psycho If you want to

Volmit Software 9 Dec 2, 2022
Payara Micro & MicroProfile Fundamentals (PMMPF)

Payara Micro & MicroProfile Fundamentals (PMMPF) In this course, you will learn the fundamentals of how to develop modern cloud-native microservices w

null 2 May 3, 2022
Event promoted by DevSuperior to improve the best practices of Spring with Java and has React JS as an additional.

Semana-Spring-React (sds3.0) Introduction SDS3 is an event promoted by DevSuperior which aims to help students and programming professionals to enter

Gilson Vieira de Souza 5 Oct 25, 2021