GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - hackware1993/XiSort: Probably the slowest sorting algorithm in the world with extremely optimized code.

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
LICENSE
LICENSE
 
 
README.md
README.md
 
 
README_CN.md
README_CN.md
 
 

Repository files navigation

The time complexity is O(n), the space complexity is O(1), and it is stable

简体中文

Dart code:

void xiSort(List<int> list) {
  int length = list.length;
  if (length < 2) {
    return;
  }
  int maxIndex = length - 1;
  int maxValue = list[0];
  int minValue = maxValue;
  for (final element in list.skip(1)) {
    if (element > maxValue) {
      maxValue = element;
    }
    if (element < minValue) {
      minValue = element;
    }
  }
  bool isSorted() {
    if (list[0] != minValue || list[maxIndex] != maxValue) {
      return false;
    }
    for (int i = 1, j = length; i < j; i++) {
      if (list[i] < list[i - 1]) {
        return false;
      }
    }
    return true;
  }
  int firstIndex;
  int secondIndex;
  int temp;
  Random random = Random();
  while (!isSorted()) {
    firstIndex = random.nextInt(length);
    secondIndex = random.nextInt(length);
    if (firstIndex != secondIndex) {
      if (list[firstIndex] != list[secondIndex]) {
        temp = list[firstIndex];
        list[firstIndex] = list[secondIndex];
        list[secondIndex] = temp;
      }
    }
  }
}

I am proud to announce that this is by far the slowest sorting algorithm with the highest code execution efficiency.

Exhausted various ways to optimize the code to the extreme. From this, we can see that there is a problem with the system, and no matter how to optimize it, it will not help.

About

Probably the slowest sorting algorithm in the world with extremely optimized code.

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.