[Question]
  [
You're given a non-empty list of positive integers, e.g.
```
[6 2 9 7 2 6 5 3 3 4]
```
You should rank these numbers by their value, but as is usual in leaderboards, if there is a tie then all the tied numbers get the same rank, and an appropriate number of ranks is skipped. The expected output for the above list would therefore be
```
[3 9 1 2 9 3 5 7 7 6]
```
For example, the highest value in the input was `9`, so this becomes a `1` (first rank). The third highest value is `6`, so both `6`s become `3`, and the rank `4` is skipped entirely.
## Rules
You can use any convenient, unambiguous, flat list format for input and output. The first/smallest rank in the output should always be **1**.
You may write a [program or a function](http://meta.codegolf.stackexchange.com/q/2419) and use any of the our [standard methods](http://meta.codegolf.stackexchange.com/q/2447) of receiving input and providing output.
You may use any [programming language](http://meta.codegolf.stackexchange.com/q/2028), but note that [these loopholes](http://meta.codegolf.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden by default.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest valid answer – measured in *bytes* – wins.
## Test Cases
```
[8] -> [1]
[1 15] -> [2 1]
[18 14 11] -> [1 2 3]
[11 16 14 8] -> [3 1 2 4]
[15 15 15 15 15] -> [1 1 1 1 1]
[10 2 5 4 15 5] -> [2 6 3 5 1 3]
[5 5 10 10 5 11 18] -> [5 5 3 3 5 2 1]
[2 4 9 4 17 9 17 16] -> [8 6 4 6 1 4 1 3]
[11 17 19 17 10 10 15 3 18] -> [6 3 1 3 7 7 5 9 2]
[2 11 4 8 3 3 12 20 4 18] -> [10 4 6 5 8 8 3 1 6 2]
[12 6 10 2 19 19 6 19 8 6 18] -> [5 8 6 11 1 1 8 1 7 8 4]
[5 6 14 19 13 5 19 9 19 9 9 19] -> [11 10 5 1 6 11 1 7 1 7 7 1]
[9 2 12 3 7 11 15 11 6 8 11 17 11] -> [8 13 3 12 10 4 2 4 11 9 4 1 4]
[3 5 15 7 18 5 3 9 11 2 18 1 10 19] -> [11 9 4 8 2 9 11 7 5 13 2 14 6 1]
[6 11 4 19 14 7 13 16 10 12 7 9 7 10 10] -> [14 6 15 1 3 11 4 2 7 5 11 10 11 7 7]
[11 20 11 1 20 16 11 11 4 8 9 7 11 14 10 14] -> [6 1 6 16 1 3 6 6 15 13 12 14 6 4 11 4]
[4 7 15 2 3 2 3 1 14 2 10 4 7 6 11 2 18] -> [9 6 2 13 11 13 11 17 3 13 5 9 6 8 4 13 1]
[5 1 17 7 1 9 3 6 9 7 6 3 2 18 14 4 18 16] -> [12 17 3 8 17 6 14 10 6 8 10 14 16 1 5 13 1 4]
[5 6 8 10 18 13 20 10 7 1 8 19 20 10 10 18 7 2 1] -> [16 15 11 7 4 6 1 7 13 18 11 3 1 7 7 4 13 17 18]
[12 17 8 2 9 7 15 6 19 5 13 16 14 20 10 11 18 4 3 1] -> [9 4 13 19 12 14 6 15 2 16 8 5 7 1 11 10 3 17 18 20]
```
  
[Answer]
# [Workaround in Excel for silly Rules Regarding Mouse Inputs on Code Golf Stack Exchange: (WESRRMICGSE)](https://drive.google.com/file/d/0B7siA0B5wdc1TDZQaEFIMU1fMUU/view?usp=sharing) 28 bytes
`rank(RC[1],r1c1:r1024:c1024)` 
Input list as csv (`10,23,34,2,`) into the compiler after entering the source. no quotes, no brackets, trailing comma.
WESRRMICGSE is exactly like programming in excel, except you can omit the initial '=' sign to save a byte. The difference in functionality comes from the fact that WESRRMICGSE will either drag the formula down to copy the code automatically and provide different outputs provided with a single integer input. provided a list as input, that list goes into the B column (input column), and the formula is drug down automatically to match the number of inputs. (eg: the input 34,21,45, would 'drag' the formula down 2 cells, for a total of 3 cells with the formula).
Edit: I never expected this answer to be popular. Wow!
[Answer]
# [MATL](http://github.com/lmendo/MATL), 4 bytes
```
&<sQ
```
[Try it online!](http://matl.tryitonline.net/#code=JjxzUQ&input=WzEyIDE3IDggMiA5IDcgMTUgNiAxOSA1IDEzIDE2IDE0IDIwIDEwIDExIDE4IDQgMyAxXQ) Or [verify all test cases](http://matl.tryitonline.net/#code=YAomPHNRCkRU&input=WzhdClsxIDE1XQpbMTggMTQgMTFdClsxMSAxNiAxNCA4XQpbMTUgMTUgMTUgMTUgMTVdClsxMCAyIDUgNCAxNSA1XQpbNSA1IDEwIDEwIDUgMTEgMThdClsyIDQgOSA0IDE3IDkgMTcgMTZdClsxMSAxNyAxOSAxNyAxMCAxMCAxNSAzIDE4XQpbMiAxMSA0IDggMyAzIDEyIDIwIDQgMThdClsxMiA2IDEwIDIgMTkgMTkgNiAxOSA4IDYgMThdCls1IDYgMTQgMTkgMTMgNSAxOSA5IDE5IDkgOSAxOV0KWzkgMiAxMiAzIDcgMTEgMTUgMTEgNiA4IDExIDE3IDExXQpbMyA1IDE1IDcgMTggNSAzIDkgMTEgMiAxOCAxIDEwIDE5XQpbNiAxMSA0IDE5IDE0IDcgMTMgMTYgMTAgMTIgNyA5IDcgMTAgMTBdClsxMSAyMCAxMSAxIDIwIDE2IDExIDExIDQgOCA5IDcgMTEgMTQgMTAgMTRdCls0IDcgMTUgMiAzIDIgMyAxIDE0IDIgMTAgNCA3IDYgMTEgMiAxOF0KWzUgMSAxNyA3IDEgOSAzIDYgOSA3IDYgMyAyIDE4IDE0IDQgMTggMTZdCls1IDYgOCAxMCAxOCAxMyAyMCAxMCA3IDEgOCAxOSAyMCAxMCAxMCAxOCA3IDIgMV0KWzEyIDE3IDggMiA5IDcgMTUgNiAxOSA1IDEzIDE2IDE0IDIwIDEwIDExIDE4IDQgMyAxXQ).
### Explanation
```
&<   % Input array implicitly. Matrix of all pairwise "less than" comparisons
s    % Sum of each column
Q    % Add 1. Display implicitly
```
[Answer]
## Python 2, 41 bytes
```
lambda l:map(sorted(l+[l])[::-1].index,l)
```
For each value, find its index in the list sorted by decreasing order. To make the largest value give 1 instead of 0, we use an extra "infinity" element of the list itself, since Python 2 treats lists as bigger than numbers.
A more direct solution is 42 bytes and also works in Python 3.
```
lambda l:[1+sum(y<x for x in l)for y in l]
```
For each element, counts the number of smaller elements, adding 1 to shift to 1-indexed.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
ṢṚiÐ€
```
[Try it online!](https://tio.run/nexus/jelly#@/9w56KHO2dlHp7wqGnN////o810FIx0FCx1FMzBDCDXVEfBGIxMYgE "Jelly – TIO Nexus")
### How it works
```
ṢṚiÐ€  Main link. Argument: A (array)
ṢṚ     Sort and reverse A.
  iÐ€  Find the index of each n in A in the previous result.
```
[Answer]
# R, 24 ~~25~~ ~~20~~ bytes
Uses the standard rank function with the "min" ties method over the negated vector. `cat` added to output it to STDOUT. Saved one thanks to @Guiseppe
```
cat(rank(-scan(),,"mi"))
```
Example
```
> cat(rank(-scan(),,"mi"))
1: 9 2 12 3 7 11 15 11 6 8 11 17 11
14: 
Read 13 items
8 13 3 12 10 4 2 4 11 9 4 1 4
> 
```
[Answer]
## PowerShell v2+, ~~43~~ 41 bytes
```
($a=$args)|%{@($a|sort -d).indexof($_)+1}
```
Developed independently, but I see that this is the same algorithm as @xnor's [Python solution](https://codegolf.stackexchange.com/a/102567/42963), so /shrug.
Takes input as individual command-line arguments (i.e., a space separated list). Output (default formatting) is a newline between elements.
For each element in the input list, it `sort`s the input list in `-d`escending order, takes the `.indexOf()` the current element, and adds `1`. Note the explicit array cast `@(...)` in order to account for a single-digit input. The resulting numbers are left on the pipeline and output is implicit.
Saved 2 bytes thanks to @Matt!
### Example
```
PS C:\Tools\Scripts\golfing> .\rank-the-integers.ps1 6 2 9 7 2 6 5 3 3 4
3
9
1
2
9
3
5
7
7
6
```
[Answer]
# Octave, 15 bytes
```
@(x)sum(x<x')+1
```
Port of my MATL answer to Octave. It also works in Matlab R2016b.
The code defines an anonymous function. To call it, assign it to a variable. [Try it at Ideone](http://ideone.com/8CeOoQ).
[Answer]
## JavaScript (ES6), ~~38~~ 36 bytes
```
a=>a.map(e=>a.map(d=>r+=e<d,r=1)&&r)
```
Edit: Saved 2 bytes thanks to @ETHproductions.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
<S‘ð€
```
**[TryItOnline!](http://jelly.tryitonline.net/#code=PFPigJjDsOKCrA&input=&args=WzYsIDIsIDksIDcsIDIsIDYsIDUsIDMsIDMsIDRd)**
### How?
```
<S‘ð€ - Main link: listOfValues
   ð  - dyadic chain separation
    € - for each
<     - less than (vectorises) - yields a list of 1s and 0s
 S    - sum - yields number of values the current value is less than (those that beat it)
  ‘   - increment - the place of a value is the number that beat it plus 1.
```
[Answer]
# [Perl 6](https://perl6.org), ~~42~~ 26 bytes
Find the first index `:k` in a reversed `[R,]` sorted list
```
{map {[R,](.sort).first(*==$^a,:k)+1},@$_}
```
Count the values that are larger, and add one
```
{map {1+.grep(*>$^a)},@$_}
```
[Answer]
# JavaScript, ~~87~~ 49 bytes
~~`f=a=>a.slice().map(function(v){return a.sort(function(a,b){return b-a}).indexOf(v)+1 })`~~
`a=>[...a].map(v=>a.sort((a,b)=>b-a).indexOf(v)+1)`
Thanks Conor O'Brien and ETHproductions!
[Answer]
## Mathematica, 44 bytes 42 bytes 40 bytes
```
xPosition[SortBy[x,-#&],#][[1,1]]&/@x
```
`` is the 3 byte private use character [`U+F4A1`](https://unicode-table.com/en/F4A1/) ([Wolfram docs page](https://reference.wolfram.com/language/ref/character/Function.html))
Edit: Thanks to [JHM](https://codegolf.stackexchange.com/users/60043/jhm) for the byte savings.
[Answer]
## Pyke, 6 bytes
```
FQS_@h
```
[Try it here!](http://pyke.catbus.co.uk/?code=FQS_%40h&input=%5B10%2C+2%2C+5%2C+4%2C+15%2C+5%5D)
```
F      - for i in input():
 QS    -     sorted(input())
   _   -    reversed(^)
    @  -   i.find(^)
     h -  ^+1 (not required if allowed to start from 0)
```
[Answer]
# [J](http://www.jsoftware.com/), ~~14~~ 8 bytes
```
1+1#.</~
```
### How?
```
1+1#.</~ - Consumes and returns a list of integers
       ~ - Use the same list for both inputs
     </  - Create a table of less-than comparisons
  1#.    - Treat each row like digits of a base-one number, returning a list of integers
1+       - Increment the results
```
### Previous solution
```
1+(+/@:<)"0 1~
```
[Answer]
## Haskell, 28 bytes
```
f l=[1+sum[1|y<-l,y>x]|x<-l]
```
Just some list comprehensions.
[Answer]
# [Wonder](https://github.com/wonderlang/wonder), 28 bytes
```
@(->@+1:0iO#0rev sort#I#1)#0
```
Usage:
```
(@(->@+1:0iO#0rev sort#I#1)#0)[6 2 9 7 2 6 5 3 3 4]
```
Map over input array with a function that adds 1 to the first index of the item in a descending-sorted version of the input.
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 7 [bytes](http://meta.codegolf.stackexchange.com/a/9429/43319)
```
⊢⍳⍨⍒⊃¨⊂
```
`⊢` arguments'
`⍳⍨` indices in
`⍒` the indices which would sort the argument descending
`⊃¨` each picked from
`⊂` the entire argument
[TryAPL online!](http://tryapl.org/?a=f%u2190%u22A2%u2373%u2368%u2352%u2283%A8%u2282%20%u22C4%20f%206%202%209%207%202%206%205%203%203%204&run)
[Answer]
# Mathematica, 37 bytes
```
Min@Position[-Sort@-#,i]~Table~{i,#}&
```
A pure function which will rank it's input, as per the rules of the problem. Ex:
```
Min@Position[-Sort@-#, i]~Table~{i, #} &[{6, 2, 9, 7, 2, 6, 5, 3, 3, 4}]
(*{3, 9, 1, 2, 9, 3, 5, 7, 7, 6}*)
```
[Answer]
## [Jellyfish](https://github.com/iatorm/jellyfish), 15 bytes
```
p`&& ~i
  >/+`<
```
[Try it online!](https://tio.run/nexus/jellyfish#@1@QoKamUJfJpaBgp6@dYPP/f7ShkYKZgqGBgpGCoSUImYEICxBlEQsA "Jellyfish – TIO Nexus")
### Explanation
There doesn't seem to be a good way to find the index of a value in a list in Jellyfish yet, so this uses the approach of counting how many values are bigger than current one and incrementing the result. This is largely done by constructing a unary function which computes this value for a given element.
```
     `<
```
This creates a threaded version of the comparison operator, so if you give this an integer and a list, it will return a list of comparison results between that integer and each element in the list.
```
     ~i
     `<
```
This curries the right-hand argument of the previous function with the input list. So the result is a unary function which takes an integer and gives you the list of comparison results with the input of the program.
```
   & ~i
   /+`<
```
Here, `/+` is reduction by addition, which means it's simply a "sum this list" function. `&` composes this onto the previous function, so we now have a unary function which *counts* how many values in the input are bigger than that integer.
```
  && ~i
  >/+`<
```
We also compose the increment function onto this.
```
 `&& ~i
  >/+`<
```
Finally, we thread this function as well, so that it's automatically applied to each integer of a list passed to it. Due to the layout of the code, `i` happens to be taken as the input of this function as well, so that this computes the desired output.
```
p`&& ~i
  >/+`<
```
Finally, this prints the result.
[Answer]
## brainfuck, 124 bytes
```
->,[>>>+>,]<[-<+]+[-->[<[<<<<]>>>+>[>[>>]<[[<<+<<]>+>[->>>>]]<+>>>]+[-<<+]->]<[<
<<<]>+.,>>[>[>->+>>]<<[-<<<<]>-]+[->+]+>>>>]
```
Formatted:
```
->
,[>>>+>,]
<[-<+]
+
[
  -->
  [
    <[<<<<]
    >>>+>
    [
      >[>>]
      <
      [
        [<<+<<]
        >+>[->>>>]
      ]
      <+> >>
    ]
    +[-<<+]
    ->
  ]
  <[<<<<]
  >+.,>>
  [
    >[>->+>>]
    <<[-<<<<]
    >-
  ]
  +[->+]
  +>>>>
]
```
This is designed for 8-bit brainfuck implementations. Input and output are via [byte values](http://meta.codegolf.stackexchange.com/questions/4708/can-numeric-input-output-be-in-the-form-of-byte-values/4719#4719).
[Try it online.](http://brainfuck.tryitonline.net/#code=LT4sWz4-Pis-LF08Wy08K10rWy0tPls8Wzw8PDxdPj4-Kz5bPls-Pl08W1s8PCs8PF0-Kz5bLT4-Pj5dXTwrPj4-XStbLTw8K10tPl08Wzw8PDxdPisuLD4-Wz5bPi0-Kz4-XTw8Wy08PDw8XT4tXStbLT4rXSs-Pj4-XQ&input=NjI5NzI2NTMzNA&debug=on)
For each element, this counts the number of elements greater than it, then prints the result plus one. This is accomplished by incrementing all elements until the current element equals zero, updating the result whenever another element becomes zero before the current element.
The tape is broken into 4-cell nodes,
`b c 0 0`
where `c` is the element and `b` is a navigation flag that is negative one for the current element, otherwise one.
The result and a copy of the current element are kept to the left of the array.
[Answer]
# Java, 215 bytes
```
public class G{public static void L(int[]A){int[]r=new int[A.length];for(int i=0;i<A.length;i++){int c=1;for(int j=0;j<A.length;j++){if(A[j]>A[i])c++;}r[i]=c;}for(int i=0;i<r.length;i++)System.out.print(r[i]+",");}}
```
Explanation:
Very self explanatory.
Basically for each integer in the array it checks how many are larger than it, then prints the new array with the rankings.
I'm sorry this isn't very concise but it's my first try at one of these and I didn't see an entry for java. I'm sure it can be golfed down more.
It can be run just by making reference to the static method and passing an array. I didn't think it was necessary to write the main function but if it is I'll do that in the future.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 5 bytes
```
m€↔O¹
```
[Try it online!](https://tio.run/##yygtzv7/P/dR05pHbVP8D@38//9/tJmOkY6ljjmQNNMx1TEGQpNYAA "Husk – Try It Online")
## Explanation
```
m€↔O¹
   O¹ sort the input in ascending order
  ↔   reverse it
m   ¹ map the input to:
 €    it's index in that list
```
[Answer]
# PHP, 101 bytes
There must be some shorter way.
```
function f(&$a){for($r=1;$v++<max($a);$r+=$n,$n=0)foreach($a as$k=>$w)if($w===$v){$a[$k]="$r";$n++;}}
```
function takes input as array of integers, overwrites input variable with ranks as numeric strings.
Usage: `$a=[1,2,4,2,2,3];f($a);print_r($a);`
[Answer]
# Ruby, ~~45~~ 40 bytes
```
->a{a.map{|x|a.sort.reverse.index(x)+1}}
```
[Answer]
# [Tcl](http://tcl.tk/), 54 bytes
```
proc R L {lmap x $L {lsearch .\ [lsort -r -de $L] $x}}
```
[Try it online!](https://tio.run/##TVJBboMwELzzijnkmgob2@A/9JRr2kNEI/VAFUSoFAnxdjqzBqkSYb07M@vZJXM/bNs4PXpc8I5l@LmNeOGk4/N@m/pvvH3gOjwf04zzhPPXneAnTq913YxMZrV0a7U4uKjQwQU4pyNLSZnBEf8eFWp4RAQV4opqYQCLfBgp7VT0JGSRWga@XNob81gKpmCPRgoJiPJK5qx4@Fpqc@CRYLdKmZVk8lJBI8yqoEYGMnJ5KRDP0nn2bM2cWUyU7140r@miCB3kJwv0ypx5VJtU7OmaIGZjK6rVWhPu85QZaV3dLZpunyzvHoKRA8nWKkL29DPMCxWQDhs2pdklm10aQtkIzW4z2K7KkmMZr7ZCYyZqE3ZyX9KCtlKXBbN3xywXP7bheAwZDpG@LS9ilV94xTL@zk9cL/pjrdsf "Tcl – Try It Online")
[Answer]
# PHP, 84 bytes
```
function r($l){$s=$l;rsort($s);foreach($l as$n)$r[]=array_search($n,$s)+1;return$r;}
```
Usage: Pass the function r your array of integers and it will return the corresponding array of ranked integers.
[Passing tests here.](http://sandbox.onlinephpfunctions.com/code/f25a46c15cf3bda0e7b0ec4ec9655f72c664430f)
[Answer]
# Perl 5, 23 +2 (-ap)
```
s/\d+/1+grep$&<$_,@F/ge
```
[Try it online](https://tio.run/##K0gtyjH9/79YPyZFW99QO70otUBFzUYlXsfBTT899f9/Q0MFQ3MFQ0swaQBGpgrGCoYW//ILSjLz84r/6yYWAAA)
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), 11 bytes
**Solution:**
```
1+(x@>x)?x:
```
[Try it online!](https://tio.run/##Dcg7CoAwEAbhq0ypiOC/JuZRqPdJYbu3XwNTfMzYvxGhbfH39vXxLkOFitEoKHOhRkYnmkzYgWZClcS8ET8 "K (oK) – Try It Online")
**Examples:**
```
1+(x@>x)?x:6 2 9 7 2 6 5 3 3 4
3 9 1 2 9 3 5 7 7 6
1+(x@>x)?x:5 6 14 19 13 5 19 9 19 9 9 19
11 10 5 1 6 11 1 7 1 7 7 1
```
**Explanation:**
Lookup position of original list in sorted list, then add one.
```
1+(x@>x)?x: / the solution
         x: / save input as x
  (  >x)    / return indices of x sorted in descending order
   x@       / apply these indices to x (thus sort x)
        ?   / lookup right in left
1+          / add one
```
[Answer]
# Clojure, ~~48~~ 44 bytes
Update: using `for` instead of `map`
```
#(for[i %](+(count(filter(partial < i)%))1))
```
Simply filters each value smaller than the current one, counts the length of the list and increments by one.
]