PHPackages                             oceanbigone/majorityjudgment - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. oceanbigone/majorityjudgment

ActiveLibrary

oceanbigone/majorityjudgment
============================

Sort candidates according to majority judgment

2.1.8(6y ago)17801[7 issues](https://github.com/oceanBigOne/MajorityJudgment/issues)MITPHPPHP &gt;=7.2.0

Since Aug 31Pushed 4y ago7 watchersCompare

[ Source](https://github.com/oceanBigOne/MajorityJudgment)[ Packagist](https://packagist.org/packages/oceanbigone/majorityjudgment)[ Docs](https://github.com/oceanBigOne/MajorityJudgment)[ RSS](/packages/oceanbigone-majorityjudgment/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)DependenciesVersions (27)Used By (0)

Majority judgment PHP
=====================

[](#majority-judgment-php)

Simple class PHP of majority judgment. See more details on [Wikipedia](https://en.wikipedia.org/wiki/Majority_judgment).

How to install ?
================

[](#how-to-install-)

`composer require oceanbigone/majorityjudgment`

How to use ?
============

[](#how-to-use-)

See how to use with `demo/index.php`. You can see result here : [demo page](http://majority-judgement-demo.garrot.org)

```
require "../vendor/autoload.php";

//start Ballot
$ballot= new Ballot();

//create Mention
$excellent  = new Mention("Excellent");
$good       = new Mention("Good");
$prettyGood = new Mention("Pretty good");
[...]

//create Candidate
$candidate1 = new Candidate("Mrs ABCDE");
$candidate2 = new Candidate("Mr FGHIJ");

//add Mentions -- from the best to the worst (order is important) !!!!
$ballot->addMention($excellent);
$ballot->addMention($good);
$ballot->addMention($prettyGood);
[...]

//add some Candidats
$ballot->addCandidate($candidate1);
$ballot->addCandidate($candidate2);
[...]

//add votes (keep in mind that each participation need a vote for each candidate !)
$ballot->addVote(new Vote($candidate1,$excellent));
$ballot->addVote(new Vote($candidate2,$prettyGood));

$ballot->addVote(new Vote($candidate1,$good));
$ballot->addVote(new Vote($candidate2,$excellent));
[...]

//get an array of candidate sorted by Majority Jugement, if there is full ex-aequo (even after index added) then they are ordered by name.
$sortedCandidates=$ballot->proceedElection();
var_dump($sortedCandidates);

//details with MeritProfile object
foreach($sortedCandidates as $candidate){

    $meritProfil=new MeritProfile();

    //get merit profil as Array of Merit object (Merit is an object with two property : mention and percent of this mention)
    $merits=$meritProfil->getAsMeritArray($candidate,$ballot->getVotes(),$ballot->getMentions());

    //display majority mention
    echo $meritProfil->processMajorityMention($candidate,$ballot->getVotes(),$ballot->getMentions()))->getLabel();

    //display percent of majority mention
    echo $meritProfil->processPercentOfMajorityMention($candidate,$ballot->getVotes(),$ballot->getMentions()));

}

//clear mentions
$ballot->clearMentions();

//clear candidates
$ballot->clearCandidates();

//clear Votes
$ballot->clearVotes();
```

Versions
========

[](#versions)

### 2.1.8

[](#218)

- Fix bug : force the sorting key to be used as a string

### 2.1.7

[](#217)

- Fix bug when perfect exaequo (add an arbitrary loop index at the end of the sorting key)

### 2.1.6

[](#216)

- Add `demo/fixture02-bug.php` to test a bug

### 2.1.5

[](#215)

- Fix bug when perfect exaequo

### 2.1.4

[](#214)

- Update this file (remove beta warning)

### 2.1.3

[](#213)

- Majority mention strictly superior 50%
- add a fixture

### 2.1.2

[](#212)

- remove var\_dump

### 2.1.1

[](#211)

- Check ex-eaquo with the full key (not only current path)

2.1.0
-----

[](#210)

- New algorithm (no more ex-aequo)

### 2.0.4

[](#204)

- Fix : bug when process worse percent than majority percent

### 2.0.3

[](#203)

- Remove key in result array

### 2.0.2

[](#202)

- fix : format key

### 2.0.1

[](#201)

- Add some help in Readme

2.0.0
-----

[](#200)

- Return objects instead of associative array
    **warning : This version is not compatible with older version**

### 1.2.8

[](#128)

- License

### 1.2.7

[](#127)

- Finalize the algorithm and add an explanation

### 1.2.6

[](#126)

- fix results error

### 1.2.5

[](#125)

- fix precision round value for generate sorting key (in result array)

### 1.2.4

[](#124)

- fix result error

### 1.2.3

[](#123)

- sign error in ex-aequo results

### 1.2.2

[](#122)

- sign error in ex-aequo results

### 1.2.1

[](#121)

- update Readme

1.2.0
-----

[](#120)

- function getMeritProfile is now private
- clean comment in code
- add some documentation

1.1.0
-----

[](#110)

- function getMeritProfile is now public
- function getAsMeritArray is now proceedElection

### 1.0.3

[](#103)

- fix composer.json

### 1.0.2

[](#102)

- add install information on Readme

### 1.0.1

[](#101)

- corrections for packagist

1.0.0
=====

[](#100)

- Initial commit

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance12

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Recently: every ~80 days

Total

24

Last Release

2301d ago

Major Versions

1.2.8 → 2.0.02018-09-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/7eb309a807cf74c26bc2a029d3de6447b4bb8c6b9bbe7c1c2a0e92cc5965650c?d=identicon)[oceanBigOne](/maintainers/oceanBigOne)

---

Tags

sortpollvoteballotdemocracymajorityjudgmentmajority-judgmentcandidate

### Embed Badge

![Health badge](/badges/oceanbigone-majorityjudgment/health.svg)

```
[![Health](https://phpackages.com/badges/oceanbigone-majorityjudgment/health.svg)](https://phpackages.com/packages/oceanbigone-majorityjudgment)
```

###  Alternatives

[spatie/eloquent-sortable

Sortable behaviour for eloquent models

1.5k22.9M268](/packages/spatie-eloquent-sortable)[kyslik/column-sortable

Package for handling column sorting in Laravel 6.x

6485.6M21](/packages/kyslik-column-sortable)[mottie/tablesorter

tablesorter (FORK) is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.

2.6k223.5k](/packages/mottie-tablesorter)[rutorika/sortable

Adds sortable behavior and ordering to Laravel Eloquent models. Grouping and many to many supported.

299992.5k14](/packages/rutorika-sortable)[willvincent/laravel-rateable

Allows multiple models to be rated with a fivestar like system.

416452.0k3](/packages/willvincent-laravel-rateable)[icecave/parity

A customizable deep comparison library.

516.8M10](/packages/icecave-parity)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
