[#83096] File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?}) — Nobuyoshi Nakada <nobu@...>
On 2017/10/04 8:47, normal@ruby-lang.org wrote:
5 messages
2017/10/04
[#83100] Re: File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?})
— Eric Wong <normalperson@...>
2017/10/04
Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
[#83105] Re: File.setuid? on IO (Re: [ruby-cvs:67289] normal:r60108 (trunk): file.c: release GVL in File.{setuid?, setgid?, sticky?})
— Nobuyoshi Nakada <nobu@...>
2017/10/04
On 2017/10/04 15:55, Eric Wong wrote:
[#83107] Alias Enumerable#include? to Enumerable#includes? — Alberto Almagro <albertoalmagro@...>
Hello,
9 messages
2017/10/04
[#83113] Re: Alias Enumerable#include? to Enumerable#includes?
— "Urabe, Shyouhei" <shyouhei@...>
2017/10/05
This has been requested countless times, then rejected each and every time.
[#83129] Re: Alias Enumerable#include? to Enumerable#includes?
— Alberto Almagro <albertoalmagro@...>
2017/10/05
Sorry I didn't found it on the core mail list's archive.
[#83138] Re: Alias Enumerable#include? to Enumerable#includes?
— "Urabe, Shyouhei" <shyouhei@...>
2017/10/06
Ruby has not been made of popular votes so far. You have to show us
[#83149] Re: Alias Enumerable#include? to Enumerable#includes?
— Eric Wong <normalperson@...>
2017/10/06
Alberto Almagro <albertoalmagro@gmail.com> wrote:
[#83200] [Ruby trunk Feature#13996] [PATCH] file.c: apply2files releases GVL — normalperson@...
Issue #13996 has been reported by normalperson (Eric Wong).
4 messages
2017/10/10
[ruby-core:83124] [Ruby trunk Feature#12648] `Enumerable#sort_by` with descending option
From:
knu@...
Date:
2017-10-05 10:00:05 UTC
List:
ruby-core #83124
Issue #12648 has been updated by knu (Akinori MUSHA).
Something like this can be a solution for sorting with multiple keys with separate ordering directions.
```ruby
module Comparable
class SortableTuple < Array
include Comparable
attr_reader :orderings
def initialize(orderings)
# Adding keyword options like `allow_nil` (`:first`/`:last`) would be great.
replace orderings.map { |key, dir|
desc =
case dir
when :desc
true
when :asc
false
else
raise ArgumentError, "direction must be either :asc or :desc: #{dir.inspect}"
end
[key, desc]
}
end
def <=>(other)
if other.instance_of?(self.class)
other.each_with_index { |(b, desc), i|
a, = self[i]
case cmp = a <=> b
when Integer
return desc ? -cmp : cmp unless cmp.zero?
else
return cmp
end
}
end
end
end
def self.[](*args)
SortableTuple.new(*args)
end
end
require 'pp'
require 'time'
pp [
["banana", Date.parse("2017-10-03")],
["apple", Date.parse("2017-10-03")],
["grape", Date.parse("2017-10-02")],
["melon", Date.parse("2017-10-02")],
["orange", Date.parse("2017-10-01")],
["cherry", Date.parse("2017-10-01")],
].sort_by { |name, date| Comparable[date => :asc, name => :desc] }
# [["apple", #<Date: 2017-10-03 ((2458030j,0s,0n),+0s,2299161j)>],
# ["banana", #<Date: 2017-10-03 ((2458030j,0s,0n),+0s,2299161j)>],
# ["grape", #<Date: 2017-10-02 ((2458029j,0s,0n),+0s,2299161j)>],
# ["melon", #<Date: 2017-10-02 ((2458029j,0s,0n),+0s,2299161j)>],
# ["cherry", #<Date: 2017-10-01 ((2458028j,0s,0n),+0s,2299161j)>],
# ["orange", #<Date: 2017-10-01 ((2458028j,0s,0n),+0s,2299161j)>]]
```
----------------------------------------
Feature #12648: `Enumerable#sort_by` with descending option
https://bugs.ruby-lang.org/issues/12648#change-67068
* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I would like to pass an optional argument to `Enumerable#sort_by` or `Enumerable#sort_by!` to allow descending sort. When the sort key is singular, this could be done by passing a single optinal boolean variable that represents ascending when `false` (default) and descending when `true`:
```ruby
[3, 1, 2].sort_by(&:itself) # => [1, 2, 3]
[3, 1, 2].sort_by(false, &:itself) # => [1, 2, 3]
[3, 1, 2].sort_by(true, &:itself) # => [3, 2, 1]
```
When there are multiple sort keys, corresponding numbers of arguments should be passed:
```ruby
[3, 1, 2, 0].sort_by{|e| [e % 2, e]} # => [0, 2, 1, 3]
[3, 1, 2, 0].sort_by(false, false){|e| [e % 2, e]} # => [0, 2, 1, 3]
[3, 1, 2, 0].sort_by(false, true){|e| [e % 2, e]} # => [2, 0, 3, 1]
[3, 1, 2, 0].sort_by(true, false){|e| [e % 2, e]} # => [1, 3, 0, 2]
[3, 1, 2, 0].sort_by(true, true){|e| [e % 2, e]} # => [3, 1, 2, 0]
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>