<commit_before>#!/usr/bin/env perl
use strict;use warnings;

use Test::More;

sub quicksort {
  my ($list) = @_;
  
  my $len = scalar(@{$list});
  
  # 1 or fewer elements in the list constitute a sorted list :)
  return $list unless ($len > 1);
  
  # Picking the middle as a pivot
  my $pivot_pos = int($len / 2);
  my $hold = undef;
  
  my $pivot_val = $list->[$pivot_pos];
  
  my $righty = $len-1;
  my $lefty = 0;
  
  while ($lefty <= $righty) {
    $lefty += 1 while ($list->[$lefty] < $pivot_val);
    $righty -= 1 while ($list->[$righty] > $pivot_val);
    
    if ($list->[$lefty] <= $list->[$righty]) {
      $hold = $list->[$lefty];
      $list->[$lefty] = $list->[$righty];
      $list->[$righty] = $hold;
      undef $hold;
      $lefty += 1;
      $righty -= 1;
    }
  }
  quicksort(@{$list}[0..$pivot_pos-1]);
  quicksort(@{$list}[$pivot_pos..$len]);
  
  return $list;
}

my @list = qw{1 6 3 9 8 6 2 5 7};
quicksort(\@list);

use Data::Dumper;
print Dumper(\@list);



<commit_msg>Finished the algorithm...<commit_after>#!/usr/bin/env perl
use strict;use warnings;

use Test::More tests => 5;
use Data::Dumper;

sub quicksort {
  my (@list) = @_;
  
  my $len = scalar(@list);
  
  # 1 or fewer elements in the list constitute a sorted list :)
  return @list unless ($len > 1);
  
  # Picking the middle as a pivot
  my $pivot_pos = int($len / 2);
  
  my $pivot_val = $list[$pivot_pos];
  
  my @greater = ();
  my @lesser = ();
  my @equal = ();
  
  my $lid = 0;
  for my $item (@list) {
    push(@lesser, $item) if ($item < $pivot_val);
    push(@equal, $item) if ($item == $pivot_val);
    push(@greater, $item) if ($item > $pivot_val);
  }
  
  return (quicksort(@lesser), @equal, quicksort(@greater));
}

my @list = qw{1 6 3 9 8 6 2 5 7};
my @output = quicksort(@list);

is(scalar(@list), scalar(@output), 'Verify we did not change the size of the lists...');
is($output[2], 3, 'Verify that item 2 is 3...');
is($output[-1], 9, 'Verify that the last item is a 9...');
is($output[4], 6, 'Verify that item 4 is a 6...');
is($list[-1], 7, 'Verify that the last item of the input was a 7...');
{'fraction_non_alphanumeric': 0.19792158715162966, 'fraction_numerical': 0.02267359470949457, 'mean_word_length': 2.981203007518797, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3544125', 'n_tokens_mistral': 866, 'n_tokens_neox': 824, 'n_words': 247}