# The repetition of results

**URL:** <https://discourse.julialang.org/t/the-repetition-of-results/103026>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [August 21, 2023, 12:49pm UTC](https://discourse.julialang.org/t/the-repetition-of-results/103026 "2023-08-21T12:49:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![R0033h](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@R0033h](https://discourse.julialang.org/u/R0033h)\
**Post date:** [August 21, 2023, 12:49pm UTC](https://discourse.julialang.org/t/the-repetition-of-results/103026/1 "2023-08-21T12:49:03Z")

</div>

I am encountering issues with the repetition of results in this code (in the terminal) I saw each result 4 times. May the problem i used the same sorted\_dic i am not sure.  
I wrote

for q in 1:4 # number of school  
standard = {Float64}()  
for i in students\_4schools  
push!(standard, S[i] \* W/ (f[i])  
end

```
     dict_standard = Dict(students_4schools[q] .=> standard)

    sorted_dict = Dict(sort(collect(dict_standard), by=x -> x[2], rev=true))

  School_one=collect(keys(sorted_dict))[1:30]
     School_two=collect(keys(sorted_dict))[1:30]
    School_three=collect(keys(sorted_dict))[1:30]
     School_four=collect(keys(sorted_dict))[1:30]

```

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 21, 2023, 1:04pm UTC](https://discourse.julialang.org/t/the-repetition-of-results/103026/2 "2023-08-21T13:04:14Z")

</div>

Please provide a working example with runnable code (just create some dummy data for `students_4schools`.

Also check that your code is working - `standard = {Float64}()` has not been valid syntax for a long time.

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [August 21, 2023, 2:40pm UTC](https://discourse.julialang.org/t/the-repetition-of-results/103026/3 "2023-08-21T14:40:40Z")

</div>

Also note that a `Dict` is a unordered collection, so sorting the entries does not work! If you need an `OrderedDict` you can use the implementation in [`OrderedCollections.jl`](https://juliacollections.github.io/OrderedCollections.jl/latest/ordered_containers.html#OrderedDicts-and-OrderedSets-1).

---

<div class="post-metadata">

**Author:** ![R0033h](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@R0033h](https://discourse.julialang.org/u/R0033h)\
**Post date:** [August 26, 2023, 8:46am UTC](https://discourse.julialang.org/t/the-repetition-of-results/103026/4 "2023-08-26T08:46:55Z")

</div>

thank you for your reply.  
itried to write just allSchools=collect(keys(sorted\_dict))[1:30] then it solved .

---

<div class="post-metadata">

**Author:** ![R0033h](https://avatars.discourse-cdn.com/v4/letter/r/b77776/32.png) [@R0033h](https://discourse.julialang.org/u/R0033h)\
**Post date:** [August 26, 2023, 8:47am UTC](https://discourse.julialang.org/t/the-repetition-of-results/103026/5 "2023-08-26T08:47:14Z")

</div>

thank you for your reply
