Skip to main content

searchsort

A Python Package that contains almost all the Searching and Sorting Algorithms

It is also available in GitHub

Installation

If there are 2 or more versions of Python installed in your system (which mostly occurs in UNIX/Linux systems) then please run any one of the commands in the BASH Shell :-

$ pip3 install searchsort
$ python3 -m pip install searchsort

If there is only Python 3.x installed in your system like in Windows systems then please run any one of commands in the Command Prompt :-

pip install searchsort
python -m pip install searchsort

Quick Guide

Please Read till the End

  • Import the Package using import searchsort as ss.
  • ss.AvailableSearchingAlgorithms() will show you the available Searching algorithms.
  • ss.AvailableSortingAlgorithms() will show you the available Sorting algorithms.
  • All the Functions have their Asymptotic Analysis in their docstrings. If you wish; you may take a note of it.

A Searching Implementation

from random import shuffle
import searchsort as ss

L1 = [i for i in range(1, 51)]
element = 20

# Shuffling the List
shuffle(L1)

index = ss.LinearSearch(L1, element)

if index:
  print(f"{element} found at :", index)
else:
  print(f"{element} not found")

Note :-

  • Some of the Algorithms require a sorted array. It is mentioned in the docstring of the functions so please read them carefully.
  • All the Algorithms return the index of the First Occurrence of the element.
  • If Element is Not Present, False is Returned.

A Sorting Implementation

from random import shuffle
import searchsort as ss

L1 = [i for i in range(1, 51)]

# Shuffling the List
shuffle(L1)
print("List Before Sorting :", L1)

Result = ss.BubbleSort(L1)
print("List After Sorting :", Result)

Note :-

  • Some of the Algorithms perform an in-place sorting, which means the structure of the Original List will be changed.
  • All the Algorithms return the sorted array, so assigning statements are preferred.

'IsSorted' Function Implementation

Besides Searching an Element in an Array and Sorting Arrays, the Package also contains an 'IsSorted' Function that Returns True if an Array is SORTED in either direction; False If NOT.

from random import shuffle
from searchsort import IsSorted

L1 = [i for i in range(1, 51)]
print("Is the List Sorted Now? ", IsSorted(L1))

# Shuffling the List
shuffle(L1)

print("Is the List Sorted Now? ", IsSorted(L1))

Metadata

Release files for searchsort 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for searchsort 0.1.6
File Size Uploaded
searchsort-0.1.6.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for searchsort 0.1.6
File Interpreter ABI Platform
searchsort-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / searchsort-0.1.6.tar.gz

Download URL searchsort-0.1.6.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
23d54061c5d390a0c7b3819c8385e3004c7d35ddbd8eea66a9311497cd3e9521
BLAKE2b-256 checksum
How to use checksums
00d08b7c8f937c903ec37d579296252eda0f45aa7a523027b084c2bac1186492
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.3

Release files / searchsort-0.1.6-py3-none-any.whl

Download URL searchsort-0.1.6-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aafe97a8dd821371655704b4be8c7f3323fa6db63ed9dff393d29c8dcc081160
BLAKE2b-256 checksum
How to use checksums
cc5034866b28b09f7f50bc1897ea268389178135322e835ff5ef8692b7b89bab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.0.2

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page